</dependency>
</dependencies>
</dependencyManagement>
-
- <profiles>
- <profile>
- <id>sfc</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netvirt-sfc</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
- </profile>
- <profile>
- <!-- When enabled, this empty profile disables the “sfc” profile above -->
- <id>no-sfc</id>
- </profile>
- </profiles>
</project>
return;
}
} catch (ReadFailedException e) {
- LOG.error("Error reading the SFC information for VPN {}", vpnName, e);
+ LOG.error("Error reading the ServiceChaining information for VPN {}", vpnName, e);
}
break;
}
vpnScHandler.bindScfOnVpnInterface(vpnIfaceAdded.key().getName(),
optScfInfoForVpn.get().getScfTag());
} catch (ReadFailedException e) {
- LOG.error("Error reading the SFC information for VPN {}", vpnName, e);
+ LOG.error("Error reading the ServiceChaining information for VPN {}", vpnName, e);
}
}
}
,,,,
DPDK,,,Full,conn-track based SNAT not supported until ovs 2.8
,,,,
- SFC classifier,Datapath,NSH based,WIP,
+ Datapath,NSH based,WIP,
,,non-NSH based,WIP,
- ,Northbound,openstack-sfc,WIP,
- ,,ODL SFC models,WIP,
+ ,Northbound,WIP,
+ ,,WIP,
,,,,
LBaaS,Octavia implementation,,Partial,"L2 supported, L3 Partially"
,ODL implementation,,Future,
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>sfc</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netvirt-sfc</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <!-- When enabled, this empty profile disables the “sfc” profile above -->
- <id>no-sfc</id>
- </profile>
- </profiles>
-
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017 Red Hat, Inc. and others.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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">
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>6.0.1</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netvirt</groupId>
- <artifactId>odl-netvirt-sfc</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <name>OpenDaylight :: NetVirt :: SFC</name>
- <packaging>feature</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-netvirt-openstack</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>odl-sfc-genius</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>odl-sfc-openflow-renderer</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sfc.classifier-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sfc.translator</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
<module>odl-netvirt-openstack</module>
</modules>
- <profiles>
- <profile>
- <id>sfc</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>odl-netvirt-sfc</module>
- </modules>
- </profile>
- <profile>
- <!-- When enabled, this empty profile disables the “sfc” profile above -->
- <id>no-sfc</id>
- </profile>
- </profiles>
-
</project>
</build>
<profiles>
- <profile>
- <id>sfc</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>sfc</module>
- </modules>
- </profile>
- <profile>
- <!-- When enabled, this empty profile disables the “sfc” profile above -->
- <id>no-sfc</id>
- </profile>
<profile>
<id>sonar-jacoco-aggregate</id>
<activation>
for Network Virtualization.
+-- net-virt-providers : Mostly contains data-path programming functionality via OpenFlow or potentially
other protocols.
- +-- net-virt-sfc : SFC implementation using the OVSDB project.
- ovsdb-ui : Contains the DLUX implementation for displaying network virtualization
+++ /dev/null
-{
- "id": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "name": "NetvirtSfc",
- "requests": [
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:redirect-sfc\": \"acl\"\n }\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\n",
- "id": "19b44f74-e2ea-9267-50af-ad79b6309859",
- "method": "PUT",
- "name": "ietf-acl redirect-sfc",
- "time": 1445298337983,
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"service-function-forwarders\": {\n \"service-function-forwarder\": [\n {\n \"name\": \"SFF1\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw2\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"service-function-type:firewall\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.71\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun2\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.71\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n },\n {\n \"name\": \"SFF2\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw4\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"dpi-74\",\n \"type\": \"service-function-type:dpi\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.73\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun4\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.73\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "1b067065-f0d5-d871-28cf-5e7e195eb463",
- "method": "PUT",
- "name": "service-function-forwarders",
- "time": 1445302610648,
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": \"true\"\n\n }\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\n",
- "id": "62e3b4d9-2672-e2bd-25c9-70bfb6771026",
- "method": "PUT",
- "name": "ietf-acl",
- "time": 1445298397905,
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"classifiers\": {\n \"classifier\": [\n {\n \"name\": \"http-classifier\",\n \"acl\": \"http-acl\",\n \"sffs\": {\n \"sff\": [\n {\n \"name\": \"sff1\"\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "id": "718ed9fd-f7f3-3862-4a53-b12d83c880ae",
- "method": "PUT",
- "name": "Classifier",
- "time": 1444924721709,
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc-classifier:classifiers",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"permit\": {}\n }\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\n",
- "id": "7412ee0c-b116-5cf1-0646-efa65f0da784",
- "method": "GET",
- "name": "ietf-acl",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"classifiers\": {\n \"classifier\": [\n {\n \"name\": \"http-classifier\",\n \"acl\": \"http-acl\",\n \"sffs\": {\n \"sff\": [\n {\n \"name\": \"sff1\"\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "id": "76b32432-5a24-9d6d-8ba2-76eb816411af",
- "method": "DELETE",
- "name": "Classifier",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc-classifier:classifiers",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"http-acl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"http-rule\",\n \"matches\": {\n \"destination-port-range\": {\n \"lower-port\": \"80\",\n \"upper-port\": \"80\"\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:redirect-sfc\": \"acl\"\n }\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\n",
- "id": "99dc6bb5-f01a-64cd-a024-c333fdf82643",
- "method": "DELETE",
- "name": "ietf-acl redirect-sfc",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n\t\"sfc\": {\n \"name\": \"sfc1\"\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "9d418a4b-197d-47c2-e85f-e68f6b5f5c40",
- "method": "GET",
- "name": "Sfc",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc:sfc/",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"classifiers\": {\n \"classifier\": [\n {\n \"name\": \"http-classifier\",\n \"acl\": \"http-acl\",\n \"sffs\": {\n \"sff\": [\n {\n \"name\": \"sff1\"\n }\n ]\n }\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "id": "b2d13061-80e0-ad8f-d0e6-d6939ea2b0a4",
- "method": "GET",
- "name": "Classifier",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc-classifier:classifiers",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"firewall-72\",\n \"ip-mgmt-address\": \"192.168.50.72\",\n \"type\": \"service-function-type:firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"2\",\n \"port\": 6633,\n \"ip\": \"192.168.50.72\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"dpi-74\",\n \"ip-mgmt-address\": \"192.168.50.74\",\n \"type\": \"service-function-type:dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"3\",\n \"port\": 6633,\n \"ip\": \"192.168.50.74\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "bf4f1148-5192-fd7d-3026-5a11668db75d",
- "method": "PUT",
- "name": "service-functions",
- "time": 1445302596335,
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/service-function:service-functions",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"service-function-forwarders\": {\n \"service-function-forwarder\": [\n {\n \"name\": \"SFF1\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw2\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"service-function-type:firewall\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.71\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun2\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.71\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n },\n {\n \"name\": \"SFF2\",\n \"service-node\": \"OVSDB2\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"sw4\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"dpi-74\",\n \"type\": \"service-function-type:dpi\",\n \"sff-sf-data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.73\",\n \"transport\": \"service-locator:vxlan-gpe\"\n }\n }\n ],\n \"sff-data-plane-locator\": [\n {\n \"name\": \"sfc-tun4\",\n \"data-plane-locator\": {\n \"transport\": \"service-locator:vxlan-gpe\",\n \"port\": 6633,\n \"ip\": \"192.168.50.73\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"remote-ip\": \"flow\",\n \"dst-port\": \"6633\",\n \"key\": \"flow\",\n \"nsp\": \"flow\",\n \"nsi\": \"flow\",\n \"nshc1\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc4\": \"flow\"\n }\n }\n ]\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "e6542ed1-832c-71c9-fe74-2d25c9e7f7ad",
- "method": "GET",
- "name": "service-function-forwarders",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n\t\"sfc\": {\n \"name\": \"sfc1\"\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "ea1c70a0-6528-862c-cabc-a9b187d483c7",
- "method": "PUT",
- "name": "Sfc",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/netvirt-sfc:sfc/",
- "version": 2
- },
- {
- "collectionId": "bc172f70-35df-2cdf-50a4-8ad09b8f17a2",
- "data": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"firewall-72\",\n \"ip-mgmt-address\": \"192.168.50.72\",\n \"type\": \"service-function-type:firewall\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"2\",\n \"port\": 6633,\n \"ip\": \"192.168.50.72\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF1\"\n }\n ]\n },\n {\n \"name\": \"dpi-74\",\n \"ip-mgmt-address\": \"192.168.50.74\",\n \"type\": \"service-function-type:dpi\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"3\",\n \"port\": 6633,\n \"ip\": \"192.168.50.74\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-forwarder\": \"SFF2\"\n }\n ]\n }\n ]\n }\n}",
- "dataMode": "raw",
- "description": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "id": "fff50fa7-aa2d-71a4-db49-4ea10b82937e",
- "method": "GET",
- "name": "service-functions",
- "responses": [],
- "timestamp": 0,
- "url": "http://localhost:8181/restconf/config/service-function:service-functions",
- "version": 2
- }
- ],
- "timestamp": 1444922427094
-}
+++ /dev/null
-{
- "id": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "name": "NetVirtSfc-v2",
- "description": "",
- "order": [
- "308700a7-ff1c-4635-eef5-be962a31bb7d",
- "a0908269-eb4a-79ac-90a3-d9837014dc6f",
- "c6439834-d4e3-b569-e3af-e11a13cf5ae0",
- "880e7cf6-1b22-16fd-162d-dba99eb77910",
- "9c663816-487b-d648-d6e0-cf333507ec03",
- "8372af4c-3ed1-5408-5cb8-3e2e6546b92f",
- "3e5806d3-b1d1-8fae-81af-bab9f52b4dd8",
- "a4036ce7-2261-69a4-45ed-f6e60e10aecd",
- "90f3e0ce-1464-58d1-556a-c7fba7597542",
- "49e03f2e-ce17-e943-c57c-03746a2dee49",
- "769366b8-93af-6b74-0c79-8f8e8672187a",
- "640c6c38-eb96-5c39-774e-b0e3345cd832",
- "c78e9578-4076-1fd3-7066-38952cf28b8d",
- "865d6bd4-720f-3a1c-bf69-051a81d508ed",
- "a1bd4157-09e1-d6a8-2ee7-8c503747511c",
- "c951da62-d97e-2438-1be6-eacb6ce6ef6c",
- "9fe30104-b3b5-b60d-f906-d6a9b720aace",
- "4b34ca17-3492-ba55-5cfc-0f8bc94f1e38",
- "eae5bb63-d729-dd2b-05ab-6e531b3966d8",
- "908af89a-15ef-0b17-13eb-d4070a7ca39d",
- "484d3b61-1d92-b112-09de-221b0c517a30",
- "93de65de-a212-abc2-05f2-e93de7d8eefa",
- "2df4a6ef-2156-04e1-a7da-bd0337779322",
- "51b325ea-5d06-a702-6873-815cda4484ce"
- ],
- "folders": [],
- "timestamp": 1461185801291,
- "owner": "516672",
- "remoteLink": "",
- "public": false,
- "requests": [
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "2df4a6ef-2156-04e1-a7da-bd0337779322",
- "name": "access-lists rsp-name",
- "description": "",
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "method": "PUT",
- "headers": "Content-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1461204989896,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"httpAcl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"httpRule\",\n \"matches\": {\n \"source-port-range\": {\n \"lower-port\": 0,\n \"upper-port\": 0\n },\n \"protocol\": 6,\n \"destination-port-range\": {\n \"lower-port\": 80,\n \"upper-port\": 80\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:rsp-name\": \"SFC-Path_rsp\",\n \"netvirt-sfc-acl:render-rsp\": false\n }\n }\n ]\n }\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "308700a7-ff1c-4635-eef5-be962a31bb7d",
- "name": "netvirt-providers-config",
- "description": "",
- "url": "http://localhost:8181/restconf/config/netvirt-providers-config:netvirt-providers-config",
- "method": "GET",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "3e5806d3-b1d1-8fae-81af-bab9f52b4dd8",
- "name": "service-functions",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function:service-functions",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "484d3b61-1d92-b112-09de-221b0c517a30",
- "name": "rendered-service-paths",
- "description": "",
- "url": "http://localhost:8181/restconf/operations/rendered-service-path:create-rendered-path",
- "method": "POST",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1461205788284,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"input\": {\n \"name\": \"SFC-Path_rsp\",\n \"parent-service-function-path\": \"SFC-Path\",\n \"symmetric\": \"false\"\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "49e03f2e-ce17-e943-c57c-03746a2dee49",
- "name": "service-function",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function:service-functions/service-function/firewall-72",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-function\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"\\\"service-function-type:firewall\",\n \"ip-mgmt-address\": \"10.2.1.1\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"sf1\",\n \"service-function-forwarder\": \"sff1\",\n \"ip\": \"10.2.1.1\",\n \"port\": \"6633\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-ovs:ovs-port\": {\n \"port-id\": \"tap-123456789ab\"\n }\n }\n ]\n }\n ]\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "4b34ca17-3492-ba55-5cfc-0f8bc94f1e38",
- "name": "service-function-paths",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-path:service-function-paths",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "51b325ea-5d06-a702-6873-815cda4484ce",
- "name": "access-lists sfc-name",
- "description": "",
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "method": "PUT",
- "headers": "Content-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"access-lists\": {\n \"acl\": [\n {\n \"acl-name\": \"httpAcl\",\n \"access-list-entries\": {\n \"ace\": [\n {\n \"rule-name\": \"httpRule\",\n \"matches\": {\n \"source-port-range\": {\n \"lower-port\": 0,\n \"upper-port\": 0\n },\n \"protocol\": 6,\n \"destination-port-range\": {\n \"lower-port\": 80,\n \"upper-port\": 80\n }\n },\n \"actions\": {\n \"netvirt-sfc-acl:sfc-name\": \"SFC\",\n \"netvirt-sfc-acl:render-rsp\": false\n }\n }\n ]\n }\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "640c6c38-eb96-5c39-774e-b0e3345cd832",
- "name": "service-function-forwarders",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1461203784214,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-function-forwarders\": {\n \"service-function-forwarder\": [\n {\n \"name\": \"sff1\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"br-int\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"sff-sf-data-plane-locator\": {\n \"sff-dpl-name\": \"vxgpe\",\n \"sf-dpl-name\": \"sf1\"\n }\n }\n ],\n \"service-function-forwarder-ovs:ovs-node\": {\n \"node-id\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://192.168.50.70:6640']\"\n },\n \"service-node\": \"ovsdb1\",\n \"sff-data-plane-locator\": [\n {\n \"name\": \"vxgpe\",\n \"data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.70\",\n \"transport\": \"service-locator:vxlan-gpe\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"nsp\": \"flow\",\n \"nshc4\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc1\": \"flow\",\n \"key\": \"flow\",\n \"dst-port\": \"6633\",\n \"nsi\": \"flow\",\n \"remote-ip\": \"flow\"\n }\n }\n ]\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "769366b8-93af-6b74-0c79-8f8e8672187a",
- "name": "service-function-forwarders",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "8372af4c-3ed1-5408-5cb8-3e2e6546b92f",
- "name": "netvirt:1",
- "description": "",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology",
- "method": "PUT",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"network-topology\": {\n \"topology\": [\n {\n \"topology-id\": \"test:1\"\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "865d6bd4-720f-3a1c-bf69-051a81d508ed",
- "name": "service-function-forwarder",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders/service-function-forwarder/sff1",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-function-forwarder\": [\n {\n \"name\": \"sff1\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"br-int\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"sff-sf-data-plane-locator\": {\n \"sff-dpl-name\": \"vxgpe\",\n \"sf-dpl-name\": \"sf1\"\n }\n }\n ],\n \"service-function-forwarder-ovs:ovs-node\": {\n \"node-id\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://192.168.50.70:6640']\"\n },\n \"service-node\": \"ovsdb1\",\n \"sff-data-plane-locator\": [\n {\n \"name\": \"vxgpe\",\n \"data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.70\",\n \"transport\": \"service-locator:vxlan-gpe\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"nsp\": \"flow\",\n \"nshc4\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc1\": \"flow\",\n \"key\": \"flow\",\n \"dst-port\": \"6633\",\n \"nsi\": \"flow\",\n \"remote-ip\": \"flow\"\n }\n }\n ]\n }\n ]\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "880e7cf6-1b22-16fd-162d-dba99eb77910",
- "name": "sfc-of-renderer-config",
- "description": "",
- "url": "http://localhost:8181/restconf/config/sfc-of-renderer:sfc-of-renderer-config ",
- "method": "PUT",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"sfc-of-renderer-config\": {\n \"sfc-of-app-egress-table-offset\": 11,\n \"sfc-of-table-offset\": 150\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "908af89a-15ef-0b17-13eb-d4070a7ca39d",
- "name": "rendered-service-paths",
- "description": "",
- "url": "http://localhost:8181/restconf/operational/rendered-service-path:rendered-service-paths",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "90f3e0ce-1464-58d1-556a-c7fba7597542",
- "name": "service-function",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function:service-functions/service-function/firewall-72",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "93de65de-a212-abc2-05f2-e93de7d8eefa",
- "name": "access-lists",
- "description": "",
- "url": "http://localhost:8181/restconf/config/ietf-access-control-list:access-lists",
- "method": "GET",
- "headers": "Content-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "9c663816-487b-d648-d6e0-cf333507ec03",
- "name": "netvirt:1",
- "description": "",
- "url": "http://localhost:8181/restconf/config/network-topology:network-topology",
- "method": "GET",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "9fe30104-b3b5-b60d-f906-d6a9b720aace",
- "name": "service-function-chains",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-chain:service-function-chains",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-function-chains\": {\n \"service-function-chain\": [\n {\n \"name\": \"SFC\",\n \"symmetric\": false,\n \"sfc-service-function\": [\n {\n \"name\": \"firewall-abstract\",\n \"type\": \"firewall\"\n }\n ]\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "a0908269-eb4a-79ac-90a3-d9837014dc6f",
- "name": "netvirt-providers-config",
- "description": "",
- "url": "http://localhost:8181/restconf/config/netvirt-providers-config:netvirt-providers-config",
- "method": "PUT",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"netvirt-providers-config\": {\n \"table-offset\": 1\n }\n}"
- },
- {
- "id": "a1bd4157-09e1-d6a8-2ee7-8c503747511c",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders/service-function-forwarder/sff1",
- "preRequestScript": "",
- "pathVariables": {},
- "method": "PUT",
- "data": [],
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "currentHelper": "normal",
- "helperAttributes": {},
- "time": 1461268899936,
- "name": "service-function-forwarder nodeId:uuid",
- "description": "This form is when the OVSDB node has connected to ODL and its OVSDB NodeId has a uuid.\n\nTo get the uuid you first GET the topology under the ovsdb:1 root. Then parse the output looking for the node you are interested in. This is typically done by searching for the br-int node with the termination-point that matches the tap port of the vm on br-int. Once that br-int node is known the managed-by value is the ovs node to be used.",
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "responses": [],
- "rawModeData": "{\n \"service-function-forwarder\": [\n {\n \"name\": \"sff1\",\n \"service-function-forwarder-ovs:ovs-bridge\": {\n \"bridge-name\": \"br-int\"\n },\n \"service-function-dictionary\": [\n {\n \"name\": \"firewall-72\",\n \"sff-sf-data-plane-locator\": {\n \"sff-dpl-name\": \"vxgpe\",\n \"sf-dpl-name\": \"sf1\"\n }\n }\n ],\n \"service-function-forwarder-ovs:ovs-node\": {\n \"node-id\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://uuid/ca80bc1d-a26b-479f-8a8a-ca3ad052a152']\"\n },\n \"service-node\": \"ovsdb1\",\n \"sff-data-plane-locator\": [\n {\n \"name\": \"vxgpe\",\n \"data-plane-locator\": {\n \"port\": 6633,\n \"ip\": \"192.168.50.70\",\n \"transport\": \"service-locator:vxlan-gpe\"\n },\n \"service-function-forwarder-ovs:ovs-options\": {\n \"nsp\": \"flow\",\n \"nshc4\": \"flow\",\n \"nshc3\": \"flow\",\n \"nshc2\": \"flow\",\n \"nshc1\": \"flow\",\n \"key\": \"flow\",\n \"dst-port\": \"6633\",\n \"nsi\": \"flow\",\n \"remote-ip\": \"flow\"\n }\n }\n ]\n }\n ]\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "a4036ce7-2261-69a4-45ed-f6e60e10aecd",
- "name": "service-functions",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function:service-functions",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1461189578583,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-functions\": {\n \"service-function\": [\n {\n \"name\": \"firewall-72\",\n \"type\": \"service-function-type:firewall\",\n \"ip-mgmt-address\": \"10.2.1.1\",\n \"nsh-aware\": \"true\",\n \"sf-data-plane-locator\": [\n {\n \"name\": \"sf1\",\n \"service-function-forwarder\": \"sff1\",\n \"ip\": \"10.2.1.1\",\n \"port\": \"6633\",\n \"transport\": \"service-locator:vxlan-gpe\",\n \"service-function-ovs:ovs-port\": {\n \"port-id\": \"tap-123456789ab\"\n }\n }\n ]\n }\n ]\n }\n}"
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "c6439834-d4e3-b569-e3af-e11a13cf5ae0",
- "name": "sfc-of-renderer-config",
- "description": "",
- "url": "http://localhost:8181/restconf/config/sfc-of-renderer:sfc-of-renderer-config ",
- "method": "GET",
- "headers": "Content-Type: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "c78e9578-4076-1fd3-7066-38952cf28b8d",
- "name": "service-function-forwarder",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-forwarder:service-function-forwarders/service-function-forwarder/sff1",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "c951da62-d97e-2438-1be6-eacb6ce6ef6c",
- "name": "service-function-chains",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-chain:service-function-chains",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": ""
- },
- {
- "collectionId": "9b368883-a4fd-3844-f29c-f682ba9a8dfd",
- "id": "eae5bb63-d729-dd2b-05ab-6e531b3966d8",
- "name": "service-function-paths",
- "description": "",
- "url": "http://localhost:8181/restconf/config/service-function-path:service-function-paths",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1461206089630,
- "preRequestScript": "",
- "tests": "",
- "rawModeData": "{\n \"service-function-paths\": {\n \"service-function-path\": [\n {\n \"name\": \"SFC-Path\",\n \"symmetric\": false,\n \"service-chain-name\": \"SFC\",\n \"starting-index\": 255\n }\n ]\n }\n}"
- }
- ]
-}
- 3-Node-Cluster-Setup-Environment-Variables.postman_environment : Postman environment file that defines variables for Restconf request for southbound plugin running in 3 node cluster environment
-- NetvirtSfc.json.postman_collection : Collection of REST-APIs to interact with Netvirt-Sfc.
-
- Ovsdb-HwvtepSouthbound-Collection.json.postman_collection : Collection contains Restconf request for doing CRUD operations (hwvtep global node, physical switch, logical switch, physical locator, and physical port) on hwvtepsouthbound plugin running in standalone controller.
- Qos-and-Queue-Collection-Environment-Variables.postman_environment : Postman environment file that defines variables used by the Qos-and-Queue-Collection.json.postman_collection
0: 'CLASSIFIER',\
20: 'GATEWAY_RESOLVER',\
10: 'DIRECTOR',\
-10: 'SFC_CLASSIFIER',\
20: 'ARP_RESPONDER',\
30: 'INBOUND_NAT',\
40: 'EGRESS_ACL',\
+++ /dev/null
-#SETUP
-
-This is a demonstration / development environment for show-casing OpenDaylight OVSDB NETVIRT with ServiceFunctionChaining (SFC)
-
-git clone https://github.com/flavio-fernandes/netvirtsfc-env.git
-
-This demo setup can also be found under the the ovsdb repo of the Opendaylight project:
-
-```
-https://github.com/opendaylight/ovsdb/tree/master/resources/demo/netvirtsfc-env
-```
-
-This demo is analogous to the demo done by the group-based-policy project of Opendaylight. In fact, the kudos
-for initially putting it together goes to our friends Keith, Thomas, and others responsible for GBP:
-
-```
-https://github.com/alagalah/gbpsfc-env
-```
-
-The initial installation may take some time, with vagrant and docker image downloads.
-
-After the first time it is very quick.
-
-1. Set up Vagrant.
- * Edit env.sh for NUM_NODES. (Keep all other vars the same for this version)
- Also set 'ODL_ROOT_DIR' to point to the directory ./openstack/net-virt-sfc/karaf/target/assembly
-
- That directory will be available when you build the ovsdb project, or where the karaf distro
- got unzipped.
-
- * Each VM takes approximately 1G RAM, 2GB used HDD (40GB)
-
- * demo-asymmetric-chain: 6 VMs.
-
-2. From the 'netvirtsfc-env' directory do:
-```
-source ./env.sh
-vagrant up
-```
- * This takes quite some time initially.
-
-3. Start controller.
- * Currently it is expected that that controller runs on the machine hosting the vagrant VMs.
- * Tested using ovsdb netvirt beryllium.
-
- * Set config for your setup:
-
- Use the script 'setsfc.sh' to make the changes below. You only need to do it once after build.
-
- * Modify the NetvirtSfc config.xml to start in standalone mode. (i.e. set of13provider to standalone)
- * Modify the logging levels to help with troubleshooting
- * Start ODL with the following feature loaded: odl-ovsdb-sfc-ui
-
- * Start controller by running bin/karaf and make sure the following features are installed
-```
- cd $ODL_ROOT_DIR ; ./bin/karaf
-```
-
-```
- opendaylight-user@root>feature:list -i | grep ovsdb-sfc
- odl-ovsdb-sfc-test | 1.2.1-SNAPSHOT | x | odl-ovsdb-sfc-test1.2.1-SNAPSHOT | OpenDaylight :: ovsdb-sfc-test
- odl-ovsdb-sfc-api | 1.2.1-SNAPSHOT | x | odl-ovsdb-sfc-1.2.1-SNAPSHOT | OpenDaylight :: ovsdb-sfc :: api
- odl-ovsdb-sfc | 1.2.1-SNAPSHOT | x | odl-ovsdb-sfc-1.2.1-SNAPSHOT | OpenDaylight :: ovsdb-sfc
- odl-ovsdb-sfc-rest | 1.2.1-SNAPSHOT | x | odl-ovsdb-sfc-1.2.1-SNAPSHOT | OpenDaylight :: ovsdb-sfc :: REST
- odl-ovsdb-sfc-ui | 1.2.1-SNAPSHOT | x | odl-ovsdb-sfc-1.2.1-SNAPSHOT | OpenDaylight :: ovsdb-sfc :: UI
-```
-
- Note that if you missed running 'setsfc.sh' ODL will operate in non-standalone mode, which is going
- to make ovsdb netvirt work with openstack/tacker environments.
-
- * Run `log:tail | grep SfcL2Renderer` and wait until the following message appears in the log:
-```
- successfully started the SfcL2Renderer plugin
-```
- * Now you can ^C the log:tail if you wish
-
-##demo-asymmetric-chain
-
- * Service Chain classifying HTTP traffic.
- * Traffic in the forward direction is chained and in the reverse direction the traffic uses the normal VxLAN tunnel
- * 2 docker containers in the same tenant space
-
-![asymmetric-chain demo diag](https://raw.githubusercontent.com/flavio-fernandes/netvirtsfc-env/master/images/asymmetric-sfc-demo.png)
-
-VMs:
-* netvirtsfc1: netvirt (client initiates transactions from here)
-* netvirtsfc2: sff
-* netvirtsfc3: "sf"
-* netvirtsfc4: sff
-* netvirtsfc5: "sf"
-* netvirtsfc6: netvirt (run a server here)
-
-Containers:
-* h35_2 is on netvirtsfc1. This host serves as the client.
-* h35_4 is netvirtsfc6. This host serves as the webserver.
-
-To run, from host folder where Vagrantfile located do:
-
-`./startdemo.sh demo-asymmetric-chain`
-
-### To test by sending traffic:
-Start a test HTTP server on h35_4 in VM 6.
-
-*(don't) forget double ENTER after `docker attach`*
-```bash
-vagrant ssh netvirtsfc6
-docker ps
-docker attach h35_4
-python -m SimpleHTTPServer 80
-```
-
-Ctrl-P-Q to detach from docker without stopping the SimpleHTTPServer, and logoff netvirtsfc6.
-
-Now start client traffic, either ping or make HTTP requests to the server on h36_4.
-
-```bash
-vagrant ssh netvirtsfc1
-docker ps
-docker attach h35_2
-ping 10.0.35.4
-curl 10.0.35.4
-while true; do curl 10.0.35.4; sleep 1; done
-```
-
-Ctrl-P-Q to detach from docker, leaving the client making HTTP requests, and logoff netvirtsfc1.
-
-Look around: use "vagrant ssh" to the various machines. To run wireshark, ssh to the vms using the -XY flags:
-```
-vagrant ssh netvirtsfcX -- -XY (e.g.: vagrant ssh netvirtsfc1 -- -XY)
-sudo wireshark &
-```
-
- * take packet captures on eth1, as that is the interface used for communication between vms.
- * sudo ovs-dpctl dump-flows
-
-
-### When finished from host folder where Vagrantfile located do:
-
-`./cleandemo.sh`
-
-If you like `vagrant destroy` will remove all VMs
-
-##Preparing to run another demo
-1. In the vagrant directory, run cleandemo.sh
-2. stop controller (logout of karaf)
-3. Remove data, journal and snapshot directories from controller directory.
-4. Restart tests starting with restarting the controller, install features, wait, as above.
+++ /dev/null
-
-# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
-VAGRANTFILE_API_VERSION = "2"
-
-Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
- odl=ENV['ODL']
- config.vm.provider "virtualbox" do |vb|
- vb.memory = "512"
- end
-
- # run our bootstrapping for the system
- config.vm.provision 'shell', path: 'bootstrap.sh', :args => odl
-
- num_nodes = (ENV['NUM_NODES'] || 1).to_i
-
- # ip configuration
- ip_base = (ENV['SUBNET'] || "192.168.50.")
- ips = num_nodes.times.collect { |n| ip_base + "#{n+70}" }
-
- num_nodes.times do |n|
- config.vm.define "netvirtsfc#{n+1}", autostart: true do |compute|
- vm_ip = ips[n]
- vm_index = n+1
- compute.vm.box = "ubuntu/trusty64"
- compute.vm.hostname = "netvirtsfc#{vm_index}"
- compute.vm.network "private_network", ip: "#{vm_ip}"
- compute.vm.provider :virtualbox do |vb|
- vb.memory = 512
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.cpus = 1
- end
- end
- end
-end
+++ /dev/null
-#!/bin/bash
-
-# vim: sw=4 ts=4 sts=4 et tw=72 :
-
-echo "---> Updating operating system"
-apt update -qq
-
-echo "---> Installing OVSDB Netvirt requirements"
-apt install -y software-properties-common -qq
-apt install -y python-software-properties -qq
-apt install -y python-pip -qq
-apt install -y git-core git -qq
-apt install -y curl -qq
-
-echo "---> Installing wireshark"
-apt install -y xbase-clients -qq
-apt install -y wireshark -qq
-
-# docker
-curl -sSL https://get.docker.com/ | sh
-
-cat <<EOL > /etc/default/docker
- DOCKER_NETWORK_OPTIONS='--bip=10.250.0.254/24'
-EOL
-
-docker pull alagalah/odlpoc_ovs230
-# OVS
-curl https://raw.githubusercontent.com/pritesh/ovs/nsh-v8/third-party/start-ovs-deb.sh | bash
-
-# this part is just for local spinup DON'T copy it to releng bootstrap.sh
-pip install ipaddr
-echo "export PATH=$PATH:/vagrant" >> /home/vagrant/.profile
-echo "export ODL=$1" >> /home/vagrant/.profile
-usermod -aG docker vagrant
+++ /dev/null
-#!/usr/bin/env bash
-
-set -e
-
-
-echo "Checking demo from $demo with vars:"
-echo "Number of nodes: " $NUM_NODES
-echo "Opendaylight Controller: " $ODL
-echo "Base subnet: " $SUBNET
-
-for i in `seq 1 $NUM_NODES`; do
- hostname="netvirtsfc"$i
- echo $hostname "flow count: "
- vagrant ssh $hostname -c "sudo ovs-ofctl dump-flows sw$i -OOpenFlow13 | wc -l "
-done
-
+++ /dev/null
-#!/usr/bin/env bash
-
-set -e
-
-for i in `seq 1 $NUM_NODES`; do
- hostname="netvirtsfc"$i
- switchname="sw"$i
- echo $hostname
- vagrant ssh $hostname -c "sudo ovs-vsctl del-br $switchname; sudo ovs-vsctl del-manager; sudo /vagrant/vmclean.sh"
-
-done
-
-./rest-clean.py
-
-if [ -f "demo.lock" ] ; then
- rm demo.lock
-fi
+++ /dev/null
-#!/usr/bin/env bash
-
-rm -rf ${ODL_ROOT_DIR}/{data,journal,snapshots}/*
+++ /dev/null
-#!/usr/bin/python
-import argparse
-import requests,json
-from requests.auth import HTTPBasicAuth
-from subprocess import call
-import time
-import sys
-import os
-
-
-DEFAULT_PORT='8181'
-
-
-USERNAME='admin'
-PASSWORD='admin'
-
-
-OPER_NODES='/restconf/operational/opendaylight-inventory:nodes/'
-CONF_TENANT='/restconf/config/policy:tenants'
-
-def get(host, port, uri):
- url='http://'+host+":"+port+uri
- #print url
- r = requests.get(url, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- jsondata=json.loads(r.text)
- return jsondata
-
-def put(host, port, uri, data, debug=False):
- '''Perform a PUT rest operation, using the URL and data provided'''
-
- url='http://'+host+":"+port+uri
-
- headers = {'Content-type': 'application/yang.data+json',
- 'Accept': 'application/yang.data+json'}
- if debug == True:
- print "PUT %s" % url
- print json.dumps(data, indent=4, sort_keys=True)
- r = requests.put(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- if debug == True:
- print r.text
- r.raise_for_status()
-
-def post(host, port, uri, data, debug=False):
- '''Perform a POST rest operation, using the URL and data provided'''
-
- url='http://'+host+":"+port+uri
- headers = {'Content-type': 'application/yang.data+json',
- 'Accept': 'application/yang.data+json'}
- if debug == True:
- print "POST %s" % url
- print json.dumps(data, indent=4, sort_keys=True)
- r = requests.post(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- if debug == True:
- print r.text
- r.raise_for_status()
-
-def get_service_functions_uri():
- return "/restconf/config/service-function:service-functions"
-
-def get_service_functions_data():
- return {
- "service-functions": {
- "service-function": [
- {
- "name": "firewall-72",
- "ip-mgmt-address": "192.168.50.72",
- "type": "service-function-type:firewall",
- "nsh-aware": "true",
- "sf-data-plane-locator": [
- {
- "name": "sf1Dpl",
- "port": 6633,
- "ip": "192.168.50.72",
- "transport": "service-locator:vxlan-gpe",
- "service-function-forwarder": "SFF1"
- }
- ]
- },
- {
- "name": "dpi-74",
- "ip-mgmt-address": "192.168.50.74",
- "type": "service-function-type:dpi",
- "nsh-aware": "true",
- "sf-data-plane-locator": [
- {
- "name": "sf2Dpl",
- "port": 6633,
- "ip": "192.168.50.74",
- "transport": "service-locator:vxlan-gpe",
- "service-function-forwarder": "SFF2"
- }
- ]
- }
- ]
- }
-}
-
-def get_service_function_forwarders_uri():
- return "/restconf/config/service-function-forwarder:service-function-forwarders"
-
-def get_service_function_forwarders_data():
- return {
- "service-function-forwarders": {
- "service-function-forwarder": [
- {
- "name": "SFF1",
- "service-node": "OVSDB2",
- "service-function-forwarder-ovs:ovs-bridge": {
- "bridge-name": "sw2"
- },
- "service-function-dictionary": [
- {
- "name": "firewall-72",
- "sff-sf-data-plane-locator": {
- "sff-dpl-name": "sfc-tun2",
- "sf-dpl-name": "sf1Dpl"
- }
- }
- ],
- "sff-data-plane-locator": [
- {
- "name": "sfc-tun2",
- "data-plane-locator": {
- "transport": "service-locator:vxlan-gpe",
- "port": 6633,
- "ip": "192.168.50.71"
- },
- "service-function-forwarder-ovs:ovs-options": {
- "remote-ip": "flow",
- "dst-port": "6633",
- "key": "flow",
- "nsp": "flow",
- "nsi": "flow",
- "nshc1": "flow",
- "nshc2": "flow",
- "nshc3": "flow",
- "nshc4": "flow"
- }
- }
- ]
- },
- {
- "name": "SFF2",
- "service-node": "OVSDB2",
- "service-function-forwarder-ovs:ovs-bridge": {
- "bridge-name": "sw4"
- },
- "service-function-dictionary": [
- {
- "name": "dpi-74",
- "sff-sf-data-plane-locator": {
- "sff-dpl-name": "sfc-tun4",
- "sf-dpl-name": "sf2Dpl"
- }
- }
- ],
- "sff-data-plane-locator": [
- {
- "name": "sfc-tun4",
- "data-plane-locator": {
- "transport": "service-locator:vxlan-gpe",
- "port": 6633,
- "ip": "192.168.50.73"
- },
- "service-function-forwarder-ovs:ovs-options": {
- "remote-ip": "flow",
- "dst-port": "6633",
- "key": "flow",
- "nsp": "flow",
- "nsi": "flow",
- "nshc1": "flow",
- "nshc2": "flow",
- "nshc3": "flow",
- "nshc4": "flow"
- }
- }
- ]
- }
- ]
- }
-}
-
-def get_service_function_chains_uri():
- return "/restconf/config/service-function-chain:service-function-chains/"
-
-def get_service_function_chains_data():
- return {
- "service-function-chains": {
- "service-function-chain": [
- {
- "name": "SFCNETVIRT",
- "symmetric": "false",
- "sfc-service-function": [
- {
- "name": "firewall-abstract1",
- "type": "service-function-type:firewall"
- },
- {
- "name": "dpi-abstract1",
- "type": "service-function-type:dpi"
- }
- ]
- }
- ]
- }
-}
-
-def get_service_function_paths_uri():
- return "/restconf/config/service-function-path:service-function-paths/"
-
-def get_service_function_paths_data():
- return {
- "service-function-paths": {
- "service-function-path": [
- {
- "name": "SFCNETVIRT-Path",
- "service-chain-name": "SFCNETVIRT",
- "starting-index": 255,
- "symmetric": "false"
-
- }
- ]
- }
-}
-
-def get_ietf_acl_uri():
- return "/restconf/config/ietf-access-control-list:access-lists"
-
-def get_ietf_acl_data():
- return {
- "access-lists": {
- "acl": [
- {
- "acl-name": "http-acl",
- "access-list-entries": {
- "ace": [
- {
- "rule-name": "http-rule",
- "matches": {
- "protocol": "6",
- "destination-port-range": {
- "lower-port": "80",
- "upper-port": "80"
- },
- },
- "actions": {
- "netvirt-sfc-acl:sfc-name": "SFCNETVIRT"
- }
- }
- ]
- }
- }
- ]
- }
- }
-
-def get_classifier_uri():
- return "/restconf/config/netvirt-sfc-classifier:classifiers"
-
-def get_classifier_data():
- return {
- "classifiers": {
- "classifier": [
- {
- "name": "http-classifier",
- "acl": "http-acl",
- "sffs": {
- "sff": [
- {
- "name": "SFF1"
- }
- ]
- },
- "bridges": {
- "bridge": [
- {
- "name": "sw1",
- "direction": "ingress"
- },
- {
- "name": "sw6",
- "direction": "egress"
- }
- ]
- }
- }
- ]
- }
- }
-
-def get_netvirt_sfc_uri():
- return "/restconf/config/netvirt-sfc:sfc/"
-
-def get_netvirt_sfc_data():
- return {
- "sfc": {
- "name": "sfc1"
- }
- }
-
-if __name__ == "__main__":
- # Launch main menu
-
-
- # Some sensible defaults
- controller=os.environ.get('ODL')
- if controller == None:
- sys.exit("No controller set.")
- else:
- print "Contacting controller at %s" % controller
-
- #tenants=get(controller,DEFAULT_PORT,CONF_TENANT)
-
- print "sending service functions"
- put(controller, DEFAULT_PORT, get_service_functions_uri(), get_service_functions_data(), True)
- print "sending service function forwarders"
- put(controller, DEFAULT_PORT, get_service_function_forwarders_uri(), get_service_function_forwarders_data(), True)
-
- print "sf's and sff's created"
- time.sleep(5)
- print "sending service function chains"
- put(controller, DEFAULT_PORT, get_service_function_chains_uri(), get_service_function_chains_data(), True)
- print "sending service function paths"
- put(controller, DEFAULT_PORT, get_service_function_paths_uri(), get_service_function_paths_data(), True)
-
- print "sfc's and sfp's created"
- time.sleep(5)
- print "sending netvirt-sfc"
- put(controller, DEFAULT_PORT, get_netvirt_sfc_uri(), get_netvirt_sfc_data(), True)
- time.sleep(1)
- print "sending ietf-acl"
- put(controller, DEFAULT_PORT, get_ietf_acl_uri(), get_ietf_acl_data(), True)
- time.sleep(1)
- print "sending classifier"
- put(controller, DEFAULT_PORT, get_classifier_uri(), get_classifier_data(), True)
-
-
- # print "sending tunnel -- SKIPPED"
- ## put(controller, DEFAULT_PORT, get_tunnel_uri(), get_tunnel_data(), True)
- # print "sending tenant -- SKIPPED"
- ## put(controller, DEFAULT_PORT, get_tenant_uri(), get_tenant_data(),True)
- # print "registering endpoints -- SKIPPED"
- ## for endpoint in get_endpoint_data():
- ## post(controller, DEFAULT_PORT, get_endpoint_uri(),endpoint,True)
-
-
+++ /dev/null
-#!/usr/bin/python
-
-from subprocess import check_output
-
-
-def call_dpctl():
- cmd="ovs-dpctl dump-flows"
- listcmd=cmd.split()
- return check_output(listcmd)
-
-if __name__ == "__main__" :
- flows=call_dpctl().split("recirc_id")
- for flow in flows:
- print flow
-
-
-
+++ /dev/null
-#!/usr/bin/env bash
-
-set -e
-hostnum=${HOSTNAME#"netvirtsfc"}
-sw="sw$hostnum"
-
-TABLE=$1
-
-clear
-ovs-ofctl dump-groups $sw -OOpenFlow13
-if [ "$TABLE" ]
-then
- ovs-ofctl dump-flows $sw -OOpenFlow13 table=$TABLE
-else
- ovs-ofctl dump-flows $sw -OOpenFlow13
-fi
-
+++ /dev/null
-#!/usr/bin/env bash
-export NUM_NODES=6
-export ODL="192.168.50.1"
-export SUBNET="192.168.50."
-
-#rootdir="/home/shague/git/ovsdb/openstack/net-virt-sfc/karaf/target/assembly"
-rootdir="/Users/ffernand/ODL/projects/ovsdb.git/openstack/net-virt-sfc/karaf/target/assembly"
-
-export ODL_ROOT_DIR=$rootdir
+++ /dev/null
-#!/usr/bin/env bash
-
-hostnum=${HOSTNAME#"netvirtsfc"}
-sw="sw$hostnum"
-set -e
-if [ "$1" ]
-then
- echo;echo "FLOWS:";ovs-ofctl dump-flows $sw -OOpenFlow13 table=$1 --rsort=priority
- echo
- printf "Flow count: "
- echo $(($(ovs-ofctl dump-flows $sw -OOpenFlow13 table=$1 | wc -l)-1))
-else
- echo;echo "FLOWS:";ovs-ofctl dump-flows $sw -OOpenFlow13
- printf "No table entered. $sw flow count: ";
- echo $(($(ovs-ofctl dump-flows $sw -OOpenFlow13 | wc -l)-1))
- printf "\nTable0: base: "; echo $(($(ovs-ofctl dump-flows $sw -OOpenFlow13 table=0| wc -l)-1))
- printf "\nTable50: sfc: "; echo $(($(ovs-ofctl dump-flows $sw -OOpenFlow13 table=6| wc -l)-1))
-fi
-
+++ /dev/null
-#!/usr/bin/python
-
-import socket
-import os
-import re
-import time
-import sys
-import ipaddr
-import commands
-from subprocess import call
-from subprocess import check_output
-from infrastructure_config import *
-
-def addController(sw, ip):
- call(['ovs-vsctl', 'set-controller', sw, 'tcp:%s:6653' % ip ])
-
-def addManager(ip):
- cmd="ovs-vsctl set-manager tcp:%s:6640" % ip
- listcmd=cmd.split()
- print check_output(listcmd)
-
-def addSwitch(name, dpid=None):
- call(['ovs-vsctl', 'add-br', name]) #Add bridge
- if dpid:
- if len(dpid) < 16: #DPID must be 16-bytes in later versions of OVS
- filler='0000000000000000'
- dpid=filler[:len(filler)-len(dpid)]+dpid
- elif len(dpid) > 16:
- print 'DPID: %s is too long' % dpid
- sys.exit(3)
- call(['ovs-vsctl','set','bridge', name,'other-config:datapath-id=%s'%dpid])
-
-def addHost(net, switch, name, ip, mac):
- containerID=launchContainer()
-
-#,OpenFlow12,OpenFlow10
-def setOFVersion(sw, version='OpenFlow13'):
- call(['ovs-vsctl', 'set', 'bridge', sw, 'protocols={}'.format(version)])
-
-def addTunnel(sw, port, sourceIp=None, remoteIp=None):
- ifaceName = '{}-vxlan-0'.format(sw)
- cmd = ['ovs-vsctl', 'add-port', sw, ifaceName,
- '--', 'set', 'Interface', ifaceName,
- 'type=vxlan',
- 'options:local_ip=%s'%sourceIp,
- 'options:remote_ip=%s'%remoteIp,
- 'options:key=4096',
- 'ofport_request=%s'%port]
-# if sourceIp is not None:
-# cmd.append('options:source_ip={}'.format(sourceIp))
- call(cmd)
-
-def addGpeTunnel(sw, sourceIp=None):
- ifaceName = '{}-vxlangpe-0'.format(sw)
- cmd = ['ovs-vsctl', 'add-port', sw, ifaceName,
- '--', 'set', 'Interface', ifaceName,
- 'type=vxlan',
- 'options:remote_ip=flow',
- 'options:dst_port=6633',
- 'options:nshc1=flow',
- 'options:nshc2=flow',
- 'options:nshc3=flow',
- 'options:nshc4=flow',
- 'options:nsp=flow',
- 'options:nsi=flow',
- 'options:key=flow',
- 'ofport_request=7']
-# if sourceIp is not None:
-# cmd.append('options:source_ip={}'.format(sourceIp))
- call(cmd)
-
-def launchContainer(host,containerImage):
- containerID= check_output(['docker','run','-d','--net=none','--name=%s'%host['name'],'-h',host['name'],'-t', '-i','--privileged=True',containerImage,'/bin/bash']) #docker run -d --net=none --name={name} -h {name} -t -i {image} /bin/bash
- #print "created container:", containerID[:-1]
- return containerID[:-1] #Remove extraneous \n from output of above
-
-def connectContainerToSwitch(sw,host,containerID,of_port):
- hostIP=host['ip']
- mac=host['mac']
- nw = ipaddr.IPv4Network(hostIP)
- broadcast = "{}".format(nw.broadcast)
- router = "{}".format(nw.network + 1)
- cmd=['/vagrant/ovswork.sh',sw,containerID,hostIP,broadcast,router,mac,of_port,host['name']]
- if host.has_key('vlan'):
- cmd.append(host['vlan'])
- call(cmd)
-
-def doCmd(cmd):
- listcmd=cmd.split()
- print check_output(listcmd)
-
-def launch(switches, hosts, contIP='127.0.0.1'):
-
- for sw in switches:
- addManager(contIP)
- ports=0
- first_host=True
- for host in hosts:
- if host['switch'] == sw['name']:
- if first_host:
- dpid=sw['dpid']
- addSwitch(sw['name'],sw['dpid'])
- setOFVersion(sw['name'])
- addController(sw['name'], contIP)
- addGpeTunnel(sw['name'])
- if host['switch'] == "sw1":
- addTunnel(sw['name'], 5, "192.168.50.70", "192.168.50.75")
- if host['switch'] == "sw6":
- addTunnel(sw['name'], 5, "192.168.50.75", "192.168.50.70")
- first_host=False
- containerImage=defaultContainerImage #from Config
- if host.has_key('container_image'): #from Config
- containerImage=host['container_image']
- containerID=launchContainer(host,containerImage)
- ports+=1
- connectContainerToSwitch(sw['name'],host,containerID,str(ports))
- host['port-name']='vethl-'+host['name']
- print "Created container: %s with IP: %s. Connect using 'docker attach %s', disconnect with ctrl-p-q." % (host['name'],host['ip'],host['name'])
-
-if __name__ == "__main__" :
-# print "Cleaning environment..."
-# doCmd('/vagrant/clean.sh')
- sw_index=int(socket.gethostname().split("netvirtsfc",1)[1])-1
- if sw_index in range(0,len(switches)+1):
-
- controller=os.environ.get('ODL')
- sw_type = switches[sw_index]['type']
- sw_name = switches[sw_index]['name']
- if sw_type == 'netvirt':
- print "*****************************"
- print "Configuring %s as a NETVIRT node." % sw_name
- print "*****************************"
- print
- launch([switches[sw_index]],hosts,controller)
- print "*****************************"
- doCmd('sudo /vagrant/utils/overlay-flows.sh')
- print "*****************************"
- print "OVS status:"
- print "-----------"
- print
- doCmd('ovs-vsctl show')
- doCmd('ovs-ofctl -O OpenFlow13 dump-flows %s'%sw_name)
- print
- print "Docker containers:"
- print "------------------"
- doCmd('docker ps')
- print "*****************************"
- elif sw_type == 'sff':
- print "*****************************"
- print "Configuring %s as an SFF." % sw_name
- print "*****************************"
- doCmd('sudo ovs-vsctl set-manager tcp:%s:6640' % controller)
- time.sleep(1)
- dpid=switches[sw_index]['dpid']
- addSwitch(sw_name,dpid)
- setOFVersion(sw_name)
- addController(sw_name, controller)
- #addGpeTunnel(sw_name)
- #doCmd('sudo ovs-vsctl set-manager tcp:%s:6640' % controller)
- print
- elif sw_type == 'sf':
- print "*****************************"
- print "Configuring %s as an SF." % sw_name
- print "*****************************"
- doCmd('sudo /vagrant/sf-config.sh')
- #addGpeTunnel(switches[sw_index]['name'])
-
+++ /dev/null
-#!/usr/bin/env bash
-set -e
-
-BRIDGE=$1
-GUEST_ID=$2
-IPADDR=$3
-BROADCAST=$4
-GWADDR=$5
-MAC=$6
-OF_PORT=$7
-GUESTNAME=$8
-VLANTAG=$9
-
-[ "$IPADDR" ] || {
- echo "Syntax:"
- echo "pipework <hostinterface> <guest> <ipaddr>/<subnet> <broadcast> <gateway> [vlan tag]"
- exit 1
-}
-
-# Step 1: Find the guest (for now, we only support LXC containers)
-while read dev mnt fstype options dump fsck
-do
- [ "$fstype" != "cgroup" ] && continue
- echo $options | grep -qw devices || continue
- CGROUPMNT=$mnt
-done < /proc/mounts
-
-[ "$CGROUPMNT" ] || {
- echo "Could not locate cgroup mount point."
- exit 1
-}
-
-N=$(find "$CGROUPMNT" -name "$GUEST_ID*" | wc -l)
-case "$N" in
- 0)
- echo "Could not find any container matching $GUEST_ID"
- exit 1
- ;;
- 1)
- true
- ;;
- *)
- echo "Found more than one container matching $GUEST_ID"
- exit 1
- ;;
-esac
-
-NSPID=$(head -n 1 $(find "$CGROUPMNT" -name "$GUEST_ID*" | head -n 1)/tasks)
-[ "$NSPID" ] || {
- echo "Could not find a process inside container $GUEST_ID"
- exit 1
-}
-
-# Step 2: Prepare the working directory
-mkdir -p /var/run/netns
-rm -f /var/run/netns/$NSPID
-ln -s /proc/$NSPID/ns/net /var/run/netns/$NSPID
-
-# Step 3: Creating virtual interfaces
-LOCAL_IFNAME=vethl-$GUESTNAME #$NSPID
-GUEST_IFNAME=vethg-$GUESTNAME #$NSPID
-ip link add name $LOCAL_IFNAME type veth peer name $GUEST_IFNAME
-ip link set $LOCAL_IFNAME up
-
-# Step 4: Adding the virtual interface to the bridge
-ip link set $GUEST_IFNAME netns $NSPID
-if [ "$VLANTAG" ]
-then
- ovs-vsctl add-port $BRIDGE $LOCAL_IFNAME tag=$VLANTAG
- echo $LOCAL_IFNAME
-else
- ovs-vsctl add-port $BRIDGE $LOCAL_IFNAME
- echo $LOCAL_IFNAME
-fi
-
-# Step 5: Configure netwroking within the container
-ip netns exec $NSPID ip link set $GUEST_IFNAME name eth0
-ip netns exec $NSPID ip addr add $IPADDR broadcast $BROADCAST dev eth0
-ip netns exec $NSPID ifconfig eth0 hw ether $MAC
-ip netns exec $NSPID ip addr add 127.0.0.1 dev lo
-ip netns exec $NSPID ip link set eth0 up
-ip netns exec $NSPID ip link set lo up
-ip netns exec $NSPID ip route add default via $GWADDR
-
+++ /dev/null
-#!/usr/bin/env bash
-TABLE=$1
-watch -n 1 -d "sudo /vagrant/flowcount.sh $1"
-
+++ /dev/null
-hostnum=${HOSTNAME#"netvirtsfc"}
-sw="sw$hostnum"
-echo "Deleting controller for $sw"
-ovs-vsctl del-controller $sw;
-if [[ $? -ne 0 ]] ; then
- exit 1
-fi
-echo "Sleeping for 6sec..."
-sleep 6
-echo "Setting controller to $ODL"
-ovs-vsctl set-controller $sw tcp:$ODL:6653
+++ /dev/null
-#!/usr/bin/python
-import argparse
-import requests,json
-from requests.auth import HTTPBasicAuth
-from subprocess import call
-import time
-import sys
-import os
-
-
-DEFAULT_PORT='8181'
-
-
-USERNAME='admin'
-PASSWORD='admin'
-
-
-OPER_NODES='/restconf/operational/opendaylight-inventory:nodes/'
-CONF_TENANT='/restconf/config/policy:tenants'
-
-def get(host, port, uri):
- url='http://'+host+":"+port+uri
- #print url
- r = requests.get(url, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- jsondata=json.loads(r.text)
- return jsondata
-
-def rest_delete(host, port, uri, debug=False):
- '''Perform a DELETE rest operation, using the URL and data provided'''
- url='http://'+host+":"+port+uri
- headers = {'Content-type': 'application/yang.data+json',
- 'Accept': 'application/yang.data+json'}
- if debug == True:
- print "DELETE %s" % url
- try:
- r = requests.delete(url, headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as e:
- print "oops: ", e
- return
- if debug == True:
- print r.text
- try:
- r.raise_for_status()
- except:
- print "oops: ", sys.exc_info()[0]
-
-
-def post(host, port, uri, data, debug=False):
- '''Perform a POST rest operation, using the URL and data provided'''
- url='http://'+host+":"+port+uri
- headers = {'Content-type': 'application/yang.data+json',
- 'Accept': 'application/yang.data+json'}
- if debug == True:
- print "POST %s" % url
- print json.dumps(data, indent=4, sort_keys=True)
- r = requests.post(url, data=json.dumps(data), headers=headers, auth=HTTPBasicAuth(USERNAME, PASSWORD))
- if debug == True:
- print r.text
- r.raise_for_status()
-
-def get_service_functions_uri():
- return "/restconf/config/service-function:service-functions"
-
-def get_service_function_forwarders_uri():
- return "/restconf/config/service-function-forwarder:service-function-forwarders"
-
-def get_service_function_chains_uri():
- return "/restconf/config/service-function-chain:service-function-chains/"
-
-def get_service_function_paths_uri():
- return "/restconf/config/service-function-path:service-function-paths/"
-
-def get_tenant_uri():
- return "/restconf/config/policy:tenants/policy:tenant/f5c7d344-d1c7-4208-8531-2c2693657e12"
-
-def get_tunnel_uri():
- return "/restconf/config/opendaylight-inventory:nodes"
-
-def get_endpoint_uri():
- return "/restconf/operations/endpoint:unregister-endpoint"
-
-def get_ietf_acl_uri():
- return "/restconf/config/ietf-access-control-list:access-lists"
-
-def get_classifier_uri():
- return "/restconf/config/netvirt-sfc-classifier:classifiers"
-
-def get_netvirt_sfc_uri():
- return "/restconf/config/netvirt-sfc:sfc/"
-
-if __name__ == "__main__":
- # Launch main menu
-
-
- # Some sensible defaults
- controller=os.environ.get('ODL')
- if controller == None:
- sys.exit("No controller set.")
- else:
- print "Contacting controller at %s" % controller
-
- #resp=get(controller,DEFAULT_PORT,'/restconf/operational/endpoint:endpoints')
- #l2_eps=resp['endpoints']['endpoint']
- #l3_eps=resp['endpoints']['endpoint-l3']
-
- print "deleting service function paths"
- rest_delete(controller, DEFAULT_PORT, get_service_function_paths_uri(), True)
-
- print "deleting service function chains"
- rest_delete(controller, DEFAULT_PORT, get_service_function_chains_uri(), True)
-
- print "deleting service functions"
- rest_delete(controller, DEFAULT_PORT, get_service_functions_uri(), True)
-
- print "deleting service function forwarders"
- rest_delete(controller, DEFAULT_PORT, get_service_function_forwarders_uri(), True)
-
- #print "deleting tunnel"
- #rest_delete(controller, DEFAULT_PORT, get_tunnel_uri(), True)
-
- #print "deleting tenant"
- #rest_delete(controller, DEFAULT_PORT, get_tenant_uri(), True)
-
- #print "unregistering L2 endpoints"
- #for endpoint in l2_eps:
- #data={ "input": { "l2": [ { "l2-context": endpoint['l2-context'] ,"mac-address": endpoint['mac-address'] } ] } }
- # post(controller, DEFAULT_PORT, get_endpoint_uri(),data,True)
-
- #print "unregistering L3 endpoints"
- #for endpoint in l3_eps:
- #data={ "input": { "l3": [ { "l3-context": endpoint['l3-context'] ,"ip-address": endpoint['ip-address'] } ] } }
- # post(controller, DEFAULT_PORT, get_endpoint_uri(),data,True)
-
- print "deleting acl"
- rest_delete(controller, DEFAULT_PORT, get_ietf_acl_uri(), True)
-
- print "deleting classifier"
- rest_delete(controller, DEFAULT_PORT, get_classifier_uri(), True)
-
- print "deleting netvirt sfc"
- rest_delete(controller, DEFAULT_PORT, get_netvirt_sfc_uri(), True)
+++ /dev/null
-#!/usr/bin/env bash
-
-ovsdbversion="1.2.1-SNAPSHOT"
-
-# Attempt to keep l2switch from monkeying with the flows
-#sed -i 's/<is-proactive-flood-mode>true<\/is-proactive-flood-mode>/<is-proactive-flood-mode>false<\/is-proactive-flood-mode>/' ${ODL_ROOT_DIR}/system/org/opendaylight/l2switch/arphandler/arphandler-config/$l2switchversion/arphandler-config-$l2switchversion-config.xml
-#sed -i 's/<is-install-lldp-flow>true<\/is-install-lldp-flow>/<is-install-lldp-flow>false<\/is-install-lldp-flow>/' ${ODL_ROOT_DIR}/system/org/opendaylight/l2switch/loopremover/loopremover-config/$l2switchversion/loopremover-config-$l2switchversion-config.xml
-
-# enable NetvirtSfc for standalone mode
-sed -i -e 's/<of13provider>[a-z]\{1,\}<\/of13provider>/<of13provider>standalone<\/of13provider>/g' ${ODL_ROOT_DIR}/system/org/opendaylight/ovsdb/openstack.net-virt-sfc-impl/$ovsdbversion/openstack.net-virt-sfc-impl-$ovsdbversion-config.xml
-
-# Automatically install the feature odl-ovsdb-sfc-ui upon ODL start
-ODL_NETVIRT_SFC_KARAF_FEATURE='odl-ovsdb-sfc-ui'
-ODLFEATUREMATCH=$(cat ${ODL_ROOT_DIR}/etc/org.apache.karaf.features.cfg | \
- grep -e "featuresBoot=" -e "featuresBoot =" | grep $ODL_NETVIRT_SFC_KARAF_FEATURE)
-if [ "$ODLFEATUREMATCH" == "" ]; then
- sed -i -e "/^featuresBoot[ ]*=/ s/$/,$ODL_NETVIRT_SFC_KARAF_FEATURE/" \
- ${ODL_ROOT_DIR}/etc/org.apache.karaf.features.cfg
-fi
-
-# Set the logging levels for troubleshooting
-logcfg=${ODL_ROOT_DIR}/etc/org.ops4j.pax.logging.cfg
-echo "log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.sfc = TRACE" >> $logcfg
-#echo "log4j.logger.org.opendaylight.ovsdb.lib = INFO" >> $logcfg
-echo "log4j.logger.org.opendaylight.sfc = TRACE" >> $logcfg
-echo "log4j.logger.org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatListenCommitFlow = ERROR" >> $logcfg
-
+++ /dev/null
-#!/usr/bin/env bash
-
-set -e
-
-demo=${1%/}
-
-echo $demo
-
-if [ -f "demo.lock" ]; then
- echo "There is already a demo running:"
- cat demo.lock
- exit
-fi
-
-cp $demo/infrastructure_config.py .
-cp $demo/sf-config.sh .
-
-echo "Starting demo from $demo with vars:"
-echo "Number of nodes: " $NUM_NODES
-echo "Opendaylight Controller: " $ODL
-echo "Base subnet: " $SUBNET
-
-for i in `seq 1 $NUM_NODES`; do
-#for i in 1 6; do
- hostname="netvirtsfc"$i
- echo $hostname
- vagrant ssh $hostname -c "sudo -E /vagrant/infrastructure_launch.py"
-done
-
-# Looks like SFC is not including l2switch anymore so this is not needed. But just in case...
-#sleep 5
-#echo "Clean l2switch flows"
-#for i in 1 2 4 6; do
-# hostname="netvirtsfc"$i
-# sw="sw"$i
-# echo $hostname
-# vagrant ssh $hostname -c "sudo ovs-ofctl -O OpenFlow13 --strict del-flows br-int priority=1,arp"
-# vagrant ssh $hostname -c "sudo ovs-ofctl -O OpenFlow13 --strict del-flows $sw priority=1,arp"
-#done
-
-echo "Configuring controller..."
-./$demo/rest.py
-
-sleep 5
-for i in 1 6; do
- hostname="netvirtsfc"$i
- sw="sw"$i
- echo $hostname
- vagrant ssh $hostname -c "sudo ovs-vsctl show; sudo ovs-ofctl -O OpenFlow13 dump-flows $sw"
-done
-
-echo "$demo" > demo.lock
-
+++ /dev/null
-ovs-appctl ofproto/trace $1
+++ /dev/null
-127.0.0.1 localhost
-192.168.50.70 netvirtsfc1
-192.168.50.71 netvirtsfc2
-192.168.50.72 netvirtsfc3
-192.168.50.73 netvirtsfc4
-192.168.50.74 netvirtsfc5
-192.168.50.75 netvirtsfc6
-
-# The following lines are desirable for IPv6 capable hosts
-::1 localhost ip6-localhost ip6-loopback
-ff02::1 ip6-allnodes
-ff02::2 ip6-allrouters
+++ /dev/null
-#!/usr/bin/env bash
-# Add flows for the normal overlay that Netvirt would have added
-# sw1: h35_2, dl_src=00:00:00:00:35:02
-# sw6: h35_4, dl_src=00:00:00:00:35:04
-
-set -e
-hostnum=${HOSTNAME#"netvirtsfc"}
-sw="sw$hostnum"
-
-if [ "$hostnum" -eq "1" ]; then
- # ARP responder for h35_4
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,arp,arp_tpa=10.0.35.4,arp_op=1 actions=move:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],set_field:00:00:00:00:35:04->eth_src,load:0x2->NXM_OF_ARP_OP[],move:NXM_NX_ARP_SHA[]->NXM_NX_ARP_THA[],load:0x000000003504->NXM_NX_ARP_SHA[],move:NXM_OF_ARP_SPA[]->NXM_OF_ARP_TPA[],load:0x0a002304->NXM_OF_ARP_SPA[],IN_PORT"
-
- #port=$(ip -o link | grep veth | awk '{print$2}' | sed 's/://')
- # l2 forward of local traffic to the normal vxlan
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,priority=150,in_port=1,dl_src=00:00:00:00:35:02,dl_dst=00:00:00:00:35:04,actions=output:5"
-
- # l2 forward of incoming vxlan traffic to the local port
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,priority=150,in_port=5,dl_src=00:00:00:00:35:04,dl_dst=00:00:00:00:35:02,actions=output:1"
-
-elif [ "$hostnum" -eq "6" ]; then
- # ARP responder for h35_4
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,arp,arp_tpa=10.0.35.2,arp_op=1 actions=move:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],set_field:00:00:00:00:35:02->eth_src,load:0x2->NXM_OF_ARP_OP[],move:NXM_NX_ARP_SHA[]->NXM_NX_ARP_THA[],load:0x000000003502->NXM_NX_ARP_SHA[],move:NXM_OF_ARP_SPA[]->NXM_OF_ARP_TPA[],load:0x0a002302->NXM_OF_ARP_SPA[],IN_PORT"
-
- # l2 forward of local traffic to the normal vxlan
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,priority=150,in_port=1,dl_src=00:00:00:00:35:04,dl_dst=00:00:00:00:35:02,actions=output:5"
-
- # l2 forward of incoming vxlan traffic to the local port
- sudo ovs-ofctl -O OpenFlow13 add-flow $sw "table=0,priority=150,in_port=5,dl_src=00:00:00:00:35:02,dl_dst=00:00:00:00:35:04,actions=output:1"
-
-else
- echo "Invalid SF for this demo";
- exit
-fi
+++ /dev/null
-#!/usr/bin/env bash
-
-set -e
-
-for i in `seq 1 $NUM_NODES`; do
- hostname="netvirtsfc"$i
- echo $hostname
- vagrant ssh $hostname -c "sudo cp /vagrant/utils/hosts /etc/hosts"
-done
-
-
+++ /dev/null
-#!/usr/bin/env bash
-
-docker stop -t=1 $(docker ps -a -q) > /dev/null 2>&1
-docker rm $(docker ps -a -q) > /dev/null 2>&1
-
-/etc/init.d/openvswitch-switch stop > /dev/null
-rm /etc/openvswitch/conf.db > /dev/null
-/etc/init.d/openvswitch-switch start > /dev/null
-
-
-ovs-vsctl show
-
'operational/odl-nat:intext-ip-map',
'operational/opendaylight-inventory:nodes'
]
-
-netvirt_sfc_data_models = [
- 'config/service-function-chain:service-function-chains',
- 'config/service-function-classifier:service-function-classifiers',
- 'config/service-function-forwarder:service-function-forwarders',
- 'config/service-function-group:service-function-groups',
- 'config/service-function-mapping:sff-dpl-by-sf-dpl-mappings',
- 'config/service-function-path:service-function-paths',
- 'config/service-function-path-metadata:service-function-metadata',
- 'config/service-function-type:service-function-types',
- 'config/service-function:service-functions',
- 'config/sfc-of-renderer:sfc-of-renderer-config',
- 'operational/rendered-service-path:rendered-service-path'
-]
services = {
0: None,
- 1: 'SFC',
- 2: 'ACL',
- 3: 'IN_CTRS',
- 4: 'SFC_CLASS',
- 5: 'DHCP',
- 6: 'QoS',
- 7: 'IPv6',
- 8: 'COE',
- 9: 'L3VPN',
- 10: 'ELAN',
- 11: 'L3VPN6'
+ 1: 'ACL',
+ 2: 'IN_CTRS',
+ 3: 'DHCP',
+ 4: 'QoS',
+ 5: 'IPv6',
+ 6: 'COE',
+ 7: 'L3VPN',
+ 8: 'ELAN',
+ 9: 'L3VPN6'
}
75: "SCF_CHAIN_FWD",
80: "L3_INTF",
81: "ARP_RESPONDER",
- 82: "SFC_TRANS_CLASS",
- 83: "SFC_TRANS_IN",
- 84: "SFC_TRANS_PMAP",
- 86: "SFC_TRANS_PMAP_NHOP",
- 87: "SFC_TRANS_EG",
90: "QOS_DSCP",
- 100: "SFC_IN_CLASS_FILTER",
- 101: "SFC_IN_CLASS_ACL",
210: "IN_ACL_ASPF",
211: "IN_ACL_CTRK_CLASS",
212: "IN_ACL_CTRK_SNDR",
217: "IN_ACL_CMTR",
219: "IN_CTRS",
220: "EG_LPORT_DISP",
- 221: "EG_SFC_CLASS_FLTR",
- 222: "EG_SFC_CLASS_NHOP",
- 223: "EG_SFC_CLASS_EG",
230: "EG_POL_CLASS",
231: "EG_POL_RT",
239: "EG_ACL_DUMMY",
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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">
-
- <parent>
- <groupId>org.opendaylight.netvirt</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <relativePath>../../../commons/binding-parent</relativePath>
- </parent>
-
- <artifactId>sfc.classifier-api</artifactId>
- <name>ODL :: netvirt :: ${project.artifactId}</name>
- <packaging>bundle</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-access-control-list</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>yang-ext</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.opendaylight.yang.gen.v1.*
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-module netvirt-sfc-acl {
- yang-version 1;
- namespace "urn:opendaylight:netvirt:sfc:acl";
- prefix "acl";
-
- import ietf-access-control-list { prefix ietf-acl; revision-date 2016-02-18; }
- import yang-ext { prefix ext; }
-
- revision "2015-01-05" {
- description "Initial revision of netvirt extensions to ietf-acl model";
- }
-
- augment "/ietf-acl:access-lists/ietf-acl:acl/ietf-acl:access-list-entries/ietf-acl:ace/ietf-acl:matches" {
- description "Neutron network uuid";
- ext:augment-identifier "neutron-network";
- leaf network-uuid {
- type string;
- }
- }
-
- augment "/ietf-acl:access-lists/ietf-acl:acl/ietf-acl:access-list-entries/ietf-acl:ace/ietf-acl:matches" {
- description "Match traffic based on its source or destination neutron port";
- ext:augment-identifier "neutron-ports";
- leaf source-port-uuid {
- type string;
- }
- leaf destination-port-uuid {
- type string;
- }
- }
-
- grouping netvirtsfc-acl-actions {
- leaf sfc-name {
- type string;
- }
- leaf sfp-name {
- type string;
- }
- leaf rsp-name {
- type string;
- }
- leaf render-rsp {
- type boolean;
- default "false";
- }
- }
-
- augment "/ietf-acl:access-lists/ietf-acl:acl/ietf-acl:access-list-entries/ietf-acl:ace/ietf-acl:actions" {
- description "Redirect traffic to SFC identified by either SFC, SFP or RSP";
- ext:augment-identifier "redirect-to-sfc";
- uses netvirtsfc-acl-actions;
- }
-}
+++ /dev/null
-module netvirt-sfc-classifier {
- yang-version 1;
- namespace "urn:opendaylight:netvirt:sfc:classifier";
- prefix "classifier";
-
- revision "2015-01-05" {
- description "Initial revision of netvirt classifier model";
- }
-
- container classifiers {
- description "Classifier container which represents the ACL being applied,
- attachment point and the associated chain";
-
- list classifier {
- description "A list of SFC classifiers";
- key "name";
- leaf name {
- type string;
- }
- leaf acl {
- type string;
- }
- container sffs {
- list sff {
- description "The classifier will be attached to these SFFs";
- key "name";
- leaf name {
- type string;
- }
- }
- }
- container bridges {
- list bridge {
- key "name";
- leaf name {
- type string;
- }
- leaf direction {
- type enumeration {
- enum ingress;
- enum egress;
- }
- }
- }
- }
- }
- }
-}
+++ /dev/null
-module netvirt-sfc {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:netvirt:sfc";
- prefix "netvirt-sfc";
-
- revision "2015-01-05" {
- description "Initial revision of the netvirt sfc model";
- }
-
- container sfc {
- leaf name {
- type string;
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2015, 2016, 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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">
-
- <parent>
- <groupId>org.opendaylight.netvirt</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <relativePath>../../../commons/binding-parent</relativePath>
- </parent>
-
- <artifactId>sfc.classifier-impl</artifactId>
- <name>ODL :: netvirt :: ${project.artifactId}</name>
- <packaging>bundle</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <properties>
- <sfc.version>0.11.0-SNAPSHOT</sfc.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.genius</groupId>
- <artifactId>interfacemanager-api</artifactId>
- <version>${genius.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.genius</groupId>
- <artifactId>mdsalutil-api</artifactId>
- <version>${genius.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.infrautils</groupId>
- <artifactId>inject</artifactId>
- <version>${infrautils.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.iana</groupId>
- <artifactId>iana-if-type</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-packet-fields</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-topology</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sfc.classifier-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>neutronvpn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin</groupId>
- <artifactId>openflowjava-extension-nicira</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin</groupId>
- <artifactId>openflowplugin-extension-nicira</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-base</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-service</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>southbound-api</artifactId>
- <version>${ovsdb.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>southbound-impl</artifactId>
- <version>${ovsdb.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-model</artifactId>
- <version>${sfc.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-provider</artifactId>
- <version>${sfc.version}</version>
- </dependency>
-
- <!-- Dependencies with <scope>test -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>testutils</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava-testlib</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>blueprint-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <!-- We purposely don't export any packages to avoid any dependencies
- on this bundle and prevent @Singleton annotated classes from being
- accidently included in another bundle's blueprint XML -->
- <Export-Package/>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.listeners;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.netvirt.sfc.classifier.service.ClassifierService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Data tree listener for AccessList.
- */
-@Singleton
-public class NetvirtSfcAclListener
- extends AsyncDataTreeChangeListenerBase<Acl, NetvirtSfcAclListener> {
-
- private final DataBroker dataBroker;
- private final ClassifierService classifierService;
-
- @Inject
- public NetvirtSfcAclListener(final DataBroker dataBroker, final ClassifierService classifierService) {
- super(Acl.class, NetvirtSfcAclListener.class);
- this.dataBroker = dataBroker;
- this.classifierService = classifierService;
- }
-
- @Override
- @PostConstruct
- public void init() {
- registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
- }
-
- @Override
- protected InstanceIdentifier<Acl> getWildCardPath() {
- return InstanceIdentifier
- .create(AccessLists.class)
- .child(Acl.class);
- }
-
- @Override
- protected NetvirtSfcAclListener getDataTreeChangeListener() {
- return this;
- }
-
- @Override
- protected void add(InstanceIdentifier<Acl> key, Acl acl) {
- classifierService.updateAll();
- }
-
- @Override
- protected void remove(InstanceIdentifier<Acl> key, Acl acl) {
- classifierService.updateAll();
- }
-
- @Override
- protected void update(InstanceIdentifier<Acl> key, Acl aclBefore, Acl aclAfter) {
- classifierService.updateAll();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.listeners;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.netvirt.sfc.classifier.service.ClassifierService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.classifier.rev150105.Classifiers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Data tree listener for Classifier.
- */
-@Singleton
-public class NetvirtSfcClassifierListener
- extends AsyncDataTreeChangeListenerBase<Classifier, NetvirtSfcClassifierListener> {
-
- private final DataBroker dataBroker;
- private final ClassifierService classifierService;
-
- @Inject
- public NetvirtSfcClassifierListener(final DataBroker dataBroker, final ClassifierService classifierService) {
- super(Classifier.class, NetvirtSfcClassifierListener.class);
-
- this.dataBroker = dataBroker;
- this.classifierService = classifierService;
- }
-
- @Override
- @PostConstruct
- public void init() {
- registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
- }
-
- @Override
- protected InstanceIdentifier<Classifier> getWildCardPath() {
- return InstanceIdentifier
- .create(Classifiers.class)
- .child(Classifier.class);
- }
-
- @Override
- protected NetvirtSfcClassifierListener getDataTreeChangeListener() {
- return this;
- }
-
- @Override
- protected void add(InstanceIdentifier<Classifier> key, Classifier classifier) {
- classifierService.updateAll();
- }
-
- @Override
- protected void remove(InstanceIdentifier<Classifier> key, Classifier classifier) {
- classifierService.updateAll();
- }
-
- @Override
- protected void update(InstanceIdentifier<Classifier> key, Classifier classifierBefore,
- Classifier classifierAfter) {
- classifierService.updateAll();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.listeners;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.netvirt.sfc.classifier.service.ClassifierService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Data tree listener for AccessList.
- */
-@Singleton
-public class NetvirtSfcRspListener extends AsyncDataTreeChangeListenerBase<RenderedServicePath, NetvirtSfcRspListener> {
-
- private final DataBroker dataBroker;
- private final ClassifierService classifierService;
-
- @Inject
- public NetvirtSfcRspListener(final DataBroker dataBroker, final ClassifierService classifierService) {
- super(RenderedServicePath.class, NetvirtSfcRspListener.class);
-
- this.dataBroker = dataBroker;
- this.classifierService = classifierService;
- }
-
- @Override
- @PostConstruct
- public void init() {
- registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
- }
-
- @Override
- protected InstanceIdentifier<RenderedServicePath> getWildCardPath() {
- return InstanceIdentifier
- .create(RenderedServicePaths.class)
- .child(RenderedServicePath.class);
- }
-
- @Override
- protected NetvirtSfcRspListener getDataTreeChangeListener() {
- return this;
- }
-
- @Override
- protected void add(InstanceIdentifier<RenderedServicePath> key, RenderedServicePath rsp) {
- classifierService.updateAll();
- }
-
- @Override
- protected void remove(InstanceIdentifier<RenderedServicePath> key, RenderedServicePath rsp) {
- classifierService.updateAll();
- }
-
- @Override
- protected void update(InstanceIdentifier<RenderedServicePath> key, RenderedServicePath rspBefore,
- RenderedServicePath rspAfter) {
- classifierService.updateAll();
- }
-}
+++ /dev/null
-/*
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.listeners;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.netvirt.sfc.classifier.service.ClassifierService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsState;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.ServiceFunctionPathState;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Data tree listener for AccessList.
- */
-@Singleton
-public class NetvirtSfcSfpListener extends
- AsyncDataTreeChangeListenerBase<ServiceFunctionPathState, NetvirtSfcSfpListener> {
-
- private final DataBroker dataBroker;
- private final ClassifierService classifierService;
-
- @Inject
- public NetvirtSfcSfpListener(final DataBroker dataBroker, final ClassifierService classifierService) {
- super(ServiceFunctionPathState.class, NetvirtSfcSfpListener.class);
-
- this.dataBroker = dataBroker;
- this.classifierService = classifierService;
- }
-
- @Override
- @PostConstruct
- public void init() {
- registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
- }
-
- @Override
- protected InstanceIdentifier<ServiceFunctionPathState> getWildCardPath() {
- return InstanceIdentifier
- .create(ServiceFunctionPathsState.class)
- .child(ServiceFunctionPathState.class);
- }
-
- @Override
- protected NetvirtSfcSfpListener getDataTreeChangeListener() {
- return this;
- }
-
- @Override
- protected void add(InstanceIdentifier<ServiceFunctionPathState> key, ServiceFunctionPathState sfp) {
- classifierService.updateAll();
- }
-
- @Override
- protected void remove(InstanceIdentifier<ServiceFunctionPathState> key, ServiceFunctionPathState sfp) {
- classifierService.updateAll();
- }
-
- @Override
- protected void update(InstanceIdentifier<ServiceFunctionPathState> key, ServiceFunctionPathState sfpBefore,
- ServiceFunctionPathState sfpAfter) {
- classifierService.updateAll();
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import com.google.common.net.InetAddresses;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.netvirt.sfc.classifier.utils.OpenFlow13Utils;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceTypeFlowBased;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfoKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.bound.services.instruction.instruction.apply.actions._case.apply.actions.action.action.ServiceBindingNxActionRegLoadApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.Uint64;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class GeniusProvider {
- private static final Logger LOG = LoggerFactory.getLogger(GeniusProvider.class);
- public static final String OPTION_KEY_REMOTE_IP = "remote_ip";
- public static final String OPTION_VALUE_FLOW = "flow";
-
- private final DataBroker dataBroker;
- private final IInterfaceManager interfaceMgr;
- private final OdlInterfaceRpcService interfaceManagerRpcService;
-
- @Inject
- public GeniusProvider(final DataBroker dataBroker, final RpcProviderRegistry rpcProviderRegistry,
- final IInterfaceManager interfaceMgr) {
- this.dataBroker = dataBroker;
- this.interfaceMgr = interfaceMgr;
- this.interfaceManagerRpcService = rpcProviderRegistry.getRpcService(OdlInterfaceRpcService.class);
- }
-
- // Package local constructor used by UT for simplification
- GeniusProvider(final DataBroker dataBroker, final OdlInterfaceRpcService interfaceManagerRpcService,
- final IInterfaceManager interfaceMgr) {
- this.dataBroker = dataBroker;
- this.interfaceMgr = interfaceMgr;
- this.interfaceManagerRpcService = interfaceManagerRpcService;
- }
-
- public void bindPortOnIngressClassifier(String interfaceName) {
- bindService(
- getBindServiceId(NwConstants.SFC_CLASSIFIER_INDEX, interfaceName, true),
- NwConstants.SFC_CLASSIFIER_INDEX,
- NwConstants.SFC_CLASSIFIER_SERVICE_NAME,
- NwConstants.SFC_SERVICE_INDEX,
- NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
- }
-
- public void bindPortOnEgressClassifier(String interfaceName, String destinationIp) {
- bindService(
- getBindServiceId(NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX, interfaceName, false),
- NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX,
- NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_NAME,
- NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX,
- NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_COOKIE,
- Collections.singletonList(
- createServiceBindingActionNxLoadReg0(
- InetAddresses.coerceToInteger(
- InetAddresses.forString(destinationIp)) & 0xffffffffL,
- 0)
- ));
- }
-
- public void unbindPortOnIngressClassifier(String interfaceName) {
- unbindService(getBindServiceId(NwConstants.SFC_CLASSIFIER_INDEX, interfaceName, true));
- }
-
- public void unbindPortOnEgressClassifier(String interfaceName) {
- unbindService(getBindServiceId(NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX, interfaceName, false));
- }
-
- public Optional<NodeId> getNodeIdFromLogicalInterface(String logicalInterface) {
- Optional<DpnIdType> dpnId = getDpnIdFromInterfaceName(logicalInterface);
-
- if (!dpnId.isPresent()) {
- LOG.warn("getNodeIdFromLogicalInterface empty dpnId for logicalInterface [{}]", logicalInterface);
- return Optional.empty();
- }
-
- return getNodeIdFromDpnId(dpnId.get());
- }
-
- public Optional<NodeId> getNodeIdFromDpnId(DpnIdType dpnId) {
- if (dpnId == null) {
- return Optional.empty();
- }
-
- if (dpnId.getValue() == null) {
- return Optional.empty();
- }
-
- return Optional.of(new NodeId("openflow:" + dpnId.getValue()));
- }
-
- // TODO Should better use the Genius InterfaceManager to avoid duplicate code
- // https://bugs.opendaylight.org/show_bug.cgi?id=8127
- public Optional<String> getIpFromDpnId(DpnIdType dpnid) {
- GetEndpointIpForDpnInputBuilder builder = new GetEndpointIpForDpnInputBuilder();
- builder.setDpid(dpnid.getValue());
- GetEndpointIpForDpnInput input = builder.build();
-
- if (interfaceManagerRpcService == null) {
- LOG.error("getIpFromDpnId({}) failed (service couldn't be retrieved)", input);
- return Optional.empty();
- }
-
- try {
- LOG.debug("getIpFromDpnId: invoking rpc");
- RpcResult<GetEndpointIpForDpnOutput> output = interfaceManagerRpcService.getEndpointIpForDpn(input).get();
- if (!output.isSuccessful()) {
- LOG.error("getIpFromDpnId({}) failed: {}", input, output);
- return Optional.empty();
- }
- LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
- List<IpAddress> localIps = output.getResult().getLocalIps();
-
- // TODO need to figure out why it returns a list, using first entry for now
- return Optional.ofNullable(localIps)
- .filter(ipAddresses -> !ipAddresses.isEmpty())
- .map(ipAddresses -> ipAddresses.get(0))
- .map(IpAddress::getIpv4Address)
- .map(Ipv4Address::getValue);
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
- }
-
- return Optional.empty();
- }
-
- public Optional<DpnIdType> getDpnIdFromInterfaceName(String interfaceName) {
- LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
- GetDpidFromInterfaceInputBuilder builder = new GetDpidFromInterfaceInputBuilder();
- builder.setIntfName(interfaceName);
- GetDpidFromInterfaceInput input = builder.build();
-
- if (interfaceManagerRpcService == null) {
- LOG.error("getDpnIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
- return Optional.empty();
- }
-
- try {
- LOG.debug("getDpnIdFromInterfaceName: invoking rpc");
- RpcResult<GetDpidFromInterfaceOutput> output = interfaceManagerRpcService.getDpidFromInterface(input).get();
- if (!output.isSuccessful()) {
- LOG.error("getDpnIdFromInterfaceName({}) failed: {}", input, output);
- return Optional.empty();
- }
-
- BigInteger dpnId = output.getResult().getDpid() != null ? output.getResult().getDpid().toJava() : null;
- if (dpnId == null) {
- return Optional.empty();
- }
- LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
-
- return Optional.of(new DpnIdType(dpnId));
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
- }
-
- return Optional.empty();
- }
-
- public Optional<String> getNodeConnectorIdFromInterfaceName(String interfaceName) {
- LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
- GetNodeconnectorIdFromInterfaceInputBuilder builder = new GetNodeconnectorIdFromInterfaceInputBuilder();
- builder.setIntfName(interfaceName);
- GetNodeconnectorIdFromInterfaceInput input = builder.build();
-
- if (interfaceManagerRpcService == null) {
- LOG.error("getNodeConnectorIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
- return Optional.empty();
- }
-
- try {
- LOG.debug("getNodeConnectorIdFromInterfaceName: invoking rpc");
- RpcResult<GetNodeconnectorIdFromInterfaceOutput> output =
- interfaceManagerRpcService.getNodeconnectorIdFromInterface(input).get();
- if (!output.isSuccessful()) {
- LOG.error("getNodeConnectorIdFromInterfaceName({}) failed: {}", input, output);
- return Optional.empty();
- }
- NodeConnectorId nodeConnId = output.getResult().getNodeconnectorId();
- if (nodeConnId == null) {
- return Optional.empty();
- }
- LOG.debug("getNodeConnectorIdFromInterfaceName({}) succeeded: {}", input, output);
-
- return Optional.ofNullable(nodeConnId.getValue());
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("getNodeConnectorIdFromInterfaceName failed to retrieve target interface name: ", e);
- }
-
- return Optional.empty();
- }
-
- public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
- List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(Uint64.valueOf(dpnId));
- if (tpList == null) {
- // Most likely the bridge doesnt exist for this dpnId
- LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]",
- dpnId);
- return Optional.empty();
- }
-
- for (OvsdbTerminationPointAugmentation tp : tpList) {
- if (tp == null) {
- // Technically we should never have a list with NULL entries, but
- // in a preliminary version of interfaceMgr.getTunnelPortsOnBridge()
- // we were getting a list where all termination point entries were
- // null. Leaving this check for now for protection.
- LOG.error("getEgressVxlanPortForNode received a NULL termination point from tpList on dpnId [{}]",
- dpnId);
- continue;
- }
-
- Class<? extends InterfaceTypeBase> ifType = tp.getInterfaceType();
- if (InterfaceTypeVxlan.class.equals(ifType)) {
- for (Options tpOption : tp.nonnullOptions()) {
- // From the VXLAN Tunnels, we want the one with the GPE option set
- if (OPTION_KEY_REMOTE_IP.equals(tpOption.key().getOption())) {
- if (OPTION_VALUE_FLOW.equals(tpOption.getValue()) && tp.getOfport() != null) {
- return Optional.ofNullable(tp.getOfport().toJava());
- }
- }
- }
- }
- }
-
- LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
-
- return Optional.empty();
- }
-
- public List<Interfaces> getInterfacesFromNode(NodeId nodeId) {
- // getPortsOnBridge() only returns Tunnel ports, so instead using getDpnInterfaceList.
- GetDpnInterfaceListInputBuilder inputBuilder = new GetDpnInterfaceListInputBuilder();
- inputBuilder.setDpid(BigInteger.valueOf(Long.parseLong(nodeId.getValue().split(":")[1])));
- GetDpnInterfaceListInput input = inputBuilder.build();
-
- try {
- LOG.debug("getInterfacesFromNode: invoking rpc");
- RpcResult<GetDpnInterfaceListOutput> output =
- interfaceManagerRpcService.getDpnInterfaceList(input).get();
- if (!output.isSuccessful()) {
- LOG.error("getInterfacesFromNode({}) failed: {}", input, output);
- return Collections.emptyList();
- }
- LOG.debug("getInterfacesFromNode({}) succeeded: {}", input, output);
- return output.getResult().getInterfaces();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("getInterfacesFromNode failed to retrieve target interface name: ", e);
- }
-
- return Collections.emptyList();
- }
-
- public InstanceIdentifier<BoundServices> getBindServiceId(short serviceId, String interfaceName,
- boolean isIngress) {
- ServicesInfoKey servicesInfoKey = isIngress
- ? new ServicesInfoKey(interfaceName, ServiceModeIngress.class) :
- new ServicesInfoKey(interfaceName, ServiceModeEgress.class);
- InstanceIdentifier<BoundServices> id = InstanceIdentifier.builder(ServiceBindings.class)
- .child(ServicesInfo.class, servicesInfoKey)
- .child(BoundServices.class, new BoundServicesKey(serviceId)).build();
-
- return id;
- }
-
- private void bindService(InstanceIdentifier<BoundServices> id, short serviceId, String serviceName,
- int servicePriority, short serviceDestTable, BigInteger serviceTableCookie) {
- bindService(
- id,
- serviceId,
- serviceName,
- servicePriority,
- serviceDestTable,
- serviceTableCookie,
- Collections.emptyList());
- }
-
- private void bindService(InstanceIdentifier<BoundServices> id, short serviceId, String serviceName,
- int servicePriority, short serviceDestTable, BigInteger serviceTableCookie, List<Action> extraActions) {
- InstructionsBuilder isb = extraActions.isEmpty()
- ? new InstructionsBuilder()
- : OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(extraActions);
- isb = OpenFlow13Utils.appendGotoTableInstruction(isb, serviceDestTable);
- StypeOpenflow stypeOpenflow = new StypeOpenflowBuilder()
- .setFlowCookie(serviceTableCookie)
- .setFlowPriority(servicePriority)
- .setInstruction(isb.build().getInstruction())
- .build();
- BoundServices boundServices = new BoundServicesBuilder().setServiceName(serviceName)
- .setServicePriority(serviceId).setServiceType(ServiceTypeFlowBased.class)
- .addAugmentation(StypeOpenflow.class, stypeOpenflow).build();
- LOG.info("Binding Service ID [{}] name [{}] priority [{}] table [{}] cookie [{}] extraActions [{}]",
- serviceId, serviceName, servicePriority, serviceDestTable, serviceTableCookie, extraActions);
-
- MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, id, boundServices);
- }
-
- private void unbindService(InstanceIdentifier<BoundServices> id) {
- MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, id);
- }
-
- public Optional<String> getRemoteIpAddress(String interfaceName) {
- return Optional.ofNullable(interfaceMgr.getInterfaceInfoFromConfigDataStore(interfaceName))
- .map(anInterface -> anInterface.augmentation(IfTunnel.class))
- .map(IfTunnel::getTunnelDestination)
- .map(IpAddress::getIpv4Address)
- .map(Ipv4Address::getValue);
- }
-
- public static Action createServiceBindingActionNxLoadReg0(long value, int order) {
- return OpenFlow13Utils.createAction(
- new ServiceBindingNxActionRegLoadApplyActionsCaseBuilder()
- .setNxRegLoad(OpenFlow13Utils.createNxLoadReg0(value))
- .build(),
- order);
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkMaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class NetvirtProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(NetvirtProvider.class);
- private final DataBroker dataBroker;
-
- @Inject
- public NetvirtProvider(final DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- public List<String> getLogicalInterfacesFromNeutronNetwork(NeutronNetwork nw) {
- InstanceIdentifier<NetworkMap> networkMapIdentifier =
- getNetworkMapIdentifier(new Uuid(nw.getNetworkUuid()));
-
- NetworkMap networkMap =
- MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier).orNull();
- if (networkMap == null) {
- LOG.warn("getLogicalInterfacesFromNeutronNetwork cant get NetworkMap for NW UUID [{}]",
- nw.getNetworkUuid());
- return Collections.emptyList();
- }
-
- List<String> interfaces = new ArrayList<>();
- List<Uuid> subnetUuidList = networkMap.getSubnetIdList();
- if (subnetUuidList != null) {
- for (Uuid subnetUuid : subnetUuidList) {
- InstanceIdentifier<Subnetmap> subnetId = getSubnetMapIdentifier(subnetUuid);
- Subnetmap subnet = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetId).orNull();
- if (subnet == null) {
- LOG.warn(
- "getLogicalInterfacesFromNeutronNetwork cant get Subnetmap for NW UUID [{}] Subnet UUID "
- + "[{}]",
- nw.getNetworkUuid(), subnetUuid.getValue());
- continue;
- }
-
- if (subnet.getPortList() == null || subnet.getPortList().isEmpty()) {
- LOG.warn("getLogicalInterfacesFromNeutronNetwork No ports on Subnet: NW UUID [{}] Subnet UUID [{}]",
- nw.getNetworkUuid(), subnetUuid.getValue());
- continue;
- }
-
- subnet.getPortList().forEach(portId -> interfaces.add(portId.getValue()));
- }
- }
-
- return interfaces;
- }
-
- //
- // Internal Util methods
- //
-
- private InstanceIdentifier<NetworkMap> getNetworkMapIdentifier(Uuid nwUuid) {
- return InstanceIdentifier.builder(NetworkMaps.class)
- .child(NetworkMap.class,new NetworkMapKey(nwUuid)).build();
- }
-
- private InstanceIdentifier<Subnetmap> getSubnetMapIdentifier(Uuid subnetUuid) {
- return InstanceIdentifier.builder(Subnetmaps.class)
- .child(Subnetmap.class, new SubnetmapKey(subnetUuid)).build();
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import com.google.common.net.InetAddresses;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import javax.inject.Singleton;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.genius.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.TypedWriteTransaction;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.netvirt.sfc.classifier.utils.AclMatches;
-import org.opendaylight.netvirt.sfc.classifier.utils.OpenFlow13Utils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Singleton
-public class OpenFlow13Provider {
- // Unique cookie values for each type of flow
- public static final BigInteger INGRESS_CLASSIFIER_FILTER_COOKIE = new BigInteger("F005BA1100000001", 16);
- public static final BigInteger INGRESS_CLASSIFIER_ACL_COOKIE = new BigInteger("F005BA1100000002", 16);
- public static final BigInteger EGRESS_CLASSIFIER_FILTER_COOKIE = new BigInteger("F005BA1100000003", 16);
- public static final BigInteger EGRESS_CLASSIFIER_NEXTHOP_COOKIE = new BigInteger("F005BA1100000004", 16);
- public static final BigInteger EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE = new BigInteger("F005BA1100000005", 16);
- public static final BigInteger INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_COOKIE =
- new BigInteger("F005BA1100000006", 16);
-
- // Priorities for each flow
- public static final int INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_PRIORITY = 10;
- public static final int INGRESS_CLASSIFIER_FILTER_CHAIN_EGRESS_PRIORITY = 520;
- public static final int INGRESS_CLASSIFIER_FILTER_NSH_TUN_PRIORITY = 510;
- public static final int INGRESS_CLASSIFIER_FILTER_NSH_PRIORITY = 511;
- public static final int INGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY = 500;
- public static final int INGRESS_CLASSIFIER_ACL_MATCH_PRIORITY = 500;
- public static final int INGRESS_CLASSIFIER_ACL_NOMATCH_PRIORITY = 10;
- public static final int EGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY = 260;
- public static final int EGRESS_CLASSIFIER_FILTER_NSH_PRIORITY = 250;
- public static final int EGRESS_CLASSIFIER_NEXTHOP_PRIORITY = 250;
- public static final int EGRESS_CLASSIFIER_EGRESS_PRIORITY = 250;
-
- // Flow names for each table
- public static final String INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_ETH_NSH_TRAFFIC_FLOW_NAME =
- "nvsfc_ingr_class_capture_sfc_tunnel_eth_nsh";
- public static final String INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_NSH_TRAFFIC_FLOW_NAME =
- "nvsfc_ingr_class_capture_sfc_tunnel_nsh";
- public static final String INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME =
- "nvsfc_ingr_class_filter_chain_egress";
- public static final String INGRESS_CLASSIFIER_FILTER_NSH_TUN_FLOW_NAME = "nvsfc_ingr_class_filter_nsh_tun";
- public static final String INGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME = "nvsfc_ingr_class_filter_nsh";
- public static final String INGRESS_CLASSIFIER_FILTER_ETH_NSH_FLOW_NAME = "nvsfc_ingr_class_filter_eth_nsh";
- public static final String INGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME = "nvsfc_ingr_class_filter_nonsh";
- public static final String INGRESS_CLASSIFIER_ACL_FLOW_NAME = "nvsfc_ingr_class_acl";
- public static final String EGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME = "nvsfc_egr_class_filter_nsh";
- public static final String EGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME = "nvsfc_egr_class_filter_nonsh";
- public static final String EGRESS_CLASSIFIER_NEXTHOP_FLOW_NAME = "nvsfc_egr_class_nexthop_noc1c2";
- public static final String EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME = "nvsfc_egr_class_ tport egress";
-
- public static final long SFC_TUNNEL_ID = 0L;
- public static final String OF_URI_SEPARATOR = ":";
- public static final Ipv4Address NULL_IP = new Ipv4Address("0.0.0.0");
-
- @Nullable
- public List<MatchBuilder> getMatchBuilderFromAceMatches(Matches matches) {
- if (matches == null) {
- return null;
- }
-
- return new AclMatches(matches).buildMatch();
- }
-
- public void appendFlowForCreate(NodeId node, Flow flow, TypedWriteTransaction<Configuration> tx) {
- NodeKey nodeKey = new NodeKey(node);
- InstanceIdentifier<Flow> iidFlow = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, nodeKey)
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(flow.getTableId()))
- .child(Flow.class, flow.key())
- .build();
-
- tx.put(iidFlow, flow, WriteTransaction.CREATE_MISSING_PARENTS);
- }
-
- public void appendFlowForDelete(NodeId node, Flow flow, TypedWriteTransaction<Configuration> tx) {
- NodeKey nodeKey = new NodeKey(node);
- InstanceIdentifier<Flow> iidFlow = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, nodeKey)
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(flow.getTableId()))
- .child(Flow.class, flow.key())
- .build();
-
- tx.delete(iidFlow);
- }
-
- /*
- * Ingress Classifier SFC Tunnel Traffic Capture Flow
- * Captures eth+nsh traffic coming from tunnel port, normalizes
- * the packet type to nsh by removing the outer ethernet header
- * and redirects it to the ingress classifier pipeline.
- */
- public Flow createIngressClassifierTunnelEthNshTrafficCaptureFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchTunId(match, SFC_TUNNEL_ID);
- OpenFlow13Utils.addMatchEthNsh(match);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxDecap(actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- OpenFlow13Utils.appendGotoTableInstruction(isb, NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- String flowIdStr = INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_ETH_NSH_TRAFFIC_FLOW_NAME + nodeId.getValue();
-
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INTERNAL_TUNNEL_TABLE,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_PRIORITY,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_COOKIE,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_ETH_NSH_TRAFFIC_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier SFC Tunnel Traffic Capture Flow
- * Captures nsh traffic coming from tunnel port,
- * and redirects it to the ingress classifier pipeline.
- */
- public Flow createIngressClassifierTunnelNshTrafficCaptureFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchTunId(match, SFC_TUNNEL_ID);
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
-
- InstructionsBuilder isb = new InstructionsBuilder();
- OpenFlow13Utils.appendGotoTableInstruction(isb, NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- String flowIdStr = INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_NSH_TRAFFIC_FLOW_NAME + nodeId.getValue();
-
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INTERNAL_TUNNEL_TABLE,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_PRIORITY,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_COOKIE,
- INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_NSH_TRAFFIC_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier Filter tunnel packet type NSH flow:
- * Prevents nsh packets coming from a tunnel port to proceed.
- * This is the least priority filter flow so it wont match
- * packets coming from other than tunnel ports.
- * Since no service port binding and thus no dispatching is
- * available on tunnel port, resubmit direct to SFC pipeline.
- */
- public Flow createIngressClassifierFilterTunnelNshFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.SFC_TRANSPORT_INGRESS_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = INGRESS_CLASSIFIER_FILTER_NSH_TUN_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- INGRESS_CLASSIFIER_FILTER_NSH_TUN_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE,
- INGRESS_CLASSIFIER_FILTER_NSH_TUN_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier Filter Eth NSH flow:
- * Prevents eth+nsh packets coming from other than a tunnel port
- * to proceed. Verify that packet are not coming from tunnel
- * by verifying there is no tunnel ip set with high priority
- * flow. Resubmit to ingress dispatcher so that other nsh
- * service handles the packet.
- */
- public Flow createIngressClassifierFilterEthNshFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchEthNsh(match);
- OpenFlow13Utils.addMatchTunDstIp(match, NULL_IP);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = INGRESS_CLASSIFIER_FILTER_ETH_NSH_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- INGRESS_CLASSIFIER_FILTER_NSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE,
- INGRESS_CLASSIFIER_FILTER_ETH_NSH_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier Filter packet type NSH floww:
- * Prevents nsh packets coming from other than a tunnel port
- * to proceed. Verify that packet are not coming from tunnel
- * by checking there is no tunnel ip set with high priority
- * flow. Resubmit to ingress dispatcher so that other nsh
- * service handles the packet.
- */
- public Flow createIngressClassifierFilterNshFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
- OpenFlow13Utils.addMatchTunDstIp(match, NULL_IP);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = INGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- INGRESS_CLASSIFIER_FILTER_NSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE,
- INGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Classifier chain termination flow:
- * Handle packets at the end of the chain for which the final
- * destination might be the classifier node.
- * Match nsh packets on classified paths at their final index.
- * Restores the lport tag on reg6, removes the nsh header and
- * resubmits to egress dispatcher.
- */
- public Flow createIngressClassifierFilterChainEgressFlow(NodeId nodeId, long nsp, short egressNsi) {
-
- MatchBuilder match = new MatchBuilder();
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
- OpenFlow13Utils.addMatchNsp(match, nsp);
- OpenFlow13Utils.addMatchNsi(match, egressNsi);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxMoveNsc4ToReg6Register(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxDecap(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- INGRESS_CLASSIFIER_FILTER_CHAIN_EGRESS_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE,
- INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier Filter No NSH flow:
- * Non nsh packets, those that have not been matched by other
- * higher priority nsh matching flows, proceed to the ACL
- * table.
- */
- public Flow createIngressClassifierFilterNoNshFlow(NodeId nodeId) {
- // MatchAny
- MatchBuilder match = new MatchBuilder();
-
- InstructionsBuilder isb = OpenFlow13Utils.appendGotoTableInstruction(new InstructionsBuilder(),
- NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE);
- String flowIdStr = INGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- INGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE,
- INGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier ACL flow:
- * Performs the ACL classification, and sends packets to back
- * to ingress dispatcher.
- * Add the in_port (corresponds to Neutron NW/tenant) to the ACL match,
- * and sets the nsp and nsi on the registry for later usage.
- */
- public Flow createIngressClassifierAclFlow(NodeId nodeId, MatchBuilder match, Long port, long nsp, short nsi) {
- OpenFlow13Utils.addMatchInPort(match, nodeId, port);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxLoadNspToReg2High(nsp, actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxLoadNsiToReg2Low(nsi, actionList.size()));
-
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
-
- // The flowIdStr needs to be unique, so the best way to make it unique is to use the match
- String flowIdStr = INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue() + match.build().toString();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE,
- INGRESS_CLASSIFIER_ACL_MATCH_PRIORITY, INGRESS_CLASSIFIER_ACL_COOKIE, INGRESS_CLASSIFIER_ACL_FLOW_NAME,
- flowIdStr, match, isb).build();
- }
-
- /*
- * Ingress Classifier ACL NoMatch flow:
- * If there are no ACL classification matches, then resubmit back to
- * the Ingress Dispatcher to let other services handle the packet.
- */
- public Flow createIngressClassifierAclNoMatchFlow(NodeId nodeId) {
- // This is a MatchAny flow
- MatchBuilder match = new MatchBuilder();
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
-
- String flowIdStr = INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE,
- INGRESS_CLASSIFIER_ACL_NOMATCH_PRIORITY, INGRESS_CLASSIFIER_ACL_COOKIE,
- INGRESS_CLASSIFIER_ACL_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- //
- // Internal EgressFlow util methods
- //
-
- /*
- * Egress Classifier Filter NoNsh flow:
- * Filters out packets that have not been classified in the
- * ingress classifier, those for which registry has not
- * been set with nsp and nsi. Resubmit to egress dispatcher.
- */
- public Flow createEgressClassifierFilterNoNshFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
-
- OpenFlow13Utils.addMatchReg2(match, 0);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = EGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- EGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY, EGRESS_CLASSIFIER_FILTER_COOKIE,
- EGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Egress Classifier Filter Nsh flow.
- * Packets proceed to NextHop table.
- */
- public Flow createEgressClassifierFilterNshFlow(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
-
- InstructionsBuilder isb = new InstructionsBuilder();
- isb = OpenFlow13Utils.appendGotoTableInstruction(isb, NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE);
- String flowIdStr = EGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE,
- EGRESS_CLASSIFIER_FILTER_NSH_PRIORITY, EGRESS_CLASSIFIER_FILTER_COOKIE,
- EGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Egress Classifier NextHop flow:
- * Encapsulates the packet and sets the NSH header values.
- * Packets proceed to TransportEgress table.
- */
- public Flow createEgressClassifierNextHopFlow(NodeId nodeId) {
- final MatchBuilder match = new MatchBuilder();
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxEncapNsh(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxMoveReg2HighToNsp(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxMoveReg2LowToNsi(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxLoadReg2(0, actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxMoveReg0ToNsc1Register(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxMoveTunIdToNsc2Register(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxMoveReg6ToNsc4Register(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxLoadTunId(SFC_TUNNEL_ID, actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- OpenFlow13Utils.appendGotoTableInstruction(isb, NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
- String flowIdStr = EGRESS_CLASSIFIER_NEXTHOP_FLOW_NAME + nodeId.getValue();
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE,
- EGRESS_CLASSIFIER_NEXTHOP_PRIORITY, EGRESS_CLASSIFIER_NEXTHOP_COOKIE,
- EGRESS_CLASSIFIER_NEXTHOP_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Egress Classifier TransportEgress Local Flow
- * First SFF is located on same node. NSH packets are
- * sent to the SFC pipeline.
- */
- public Flow createEgressClassifierTransportEgressLocalFlow(NodeId nodeId, long nsp) {
- MatchBuilder match = new MatchBuilder();
-
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
- OpenFlow13Utils.addMatchNsp(match, nsp);
-
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.SFC_TRANSPORT_INGRESS_TABLE,
- actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE,
- EGRESS_CLASSIFIER_EGRESS_PRIORITY, EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE,
- EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Egress Classifier TransportEgress Remote Flow
- * Sends packet to a remote SFF ip though a tunnel port.
- * Packets are not encapsulated with an extra ethernet header.
- */
- public Flow createEgressClassifierTransportEgressRemoteNshFlow(NodeId nodeId, long nsp, long outport,
- String firstHopIp) {
- MatchBuilder match = new MatchBuilder();
-
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
- OpenFlow13Utils.addMatchNsp(match, nsp);
-
- Long ipl = InetAddresses.coerceToInteger(InetAddresses.forString(firstHopIp)) & 0xffffffffL;
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxLoadTunIpv4Dst(ipl, actionList.size()));
- actionList.add(OpenFlow13Utils.createActionOutPort("output:" + outport, actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE,
- EGRESS_CLASSIFIER_EGRESS_PRIORITY, EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE,
- EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
- /*
- * Egress Classifier TransportEgress Remote Flow
- * Sends packet to a remote SFF ip though a tunnel port.
- * Packets are encapsulated with an extra ethernet header.
- */
- public Flow createEgressClassifierTransportEgressRemoteEthNshFlow(NodeId nodeId, long nsp, long outport,
- String firstHopIp) {
- MatchBuilder match = new MatchBuilder();
-
- OpenFlow13Utils.addMatchPacketTypeNsh(match);
- OpenFlow13Utils.addMatchNsp(match, nsp);
-
- Long ipl = InetAddresses.coerceToInteger(InetAddresses.forString(firstHopIp)) & 0xffffffffL;
- List<Action> actionList = new ArrayList<>();
- actionList.add(OpenFlow13Utils.createActionNxEncapEthernet(actionList.size()));
- actionList.add(OpenFlow13Utils.createActionNxLoadTunIpv4Dst(ipl, actionList.size()));
- actionList.add(OpenFlow13Utils.createActionOutPort("output:" + outport, actionList.size()));
-
- InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
- String flowIdStr = EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
-
- return OpenFlow13Utils.createFlowBuilder(NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE,
- EGRESS_CLASSIFIER_EGRESS_PRIORITY, EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE,
- EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME, flowIdStr, match, isb).build();
- }
-
-
-
- public static Long getPortNoFromNodeConnector(String connector) {
- /*
- * NodeConnectorId is of the form 'openflow:dpnid:portnum'
- */
- return Long.valueOf(connector.split(OF_URI_SEPARATOR)[2]);
- }
-
- public static BigInteger getDpnIdFromNodeId(NodeId nodeId) {
- /*
- * NodeId is of the form 'openflow:dpnid'
- */
- return BigInteger.valueOf(Long.parseLong(nodeId.getValue().split(OF_URI_SEPARATOR)[1]));
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarderBase;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsState;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.ServiceFunctionPathState;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.ServiceFunctionPathStateKey;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.LogicalInterfaceLocator;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterface;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class SfcProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(SfcProvider.class);
- private final DataBroker dataBroker;
-
- @Inject
- public SfcProvider(final DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- public Optional<RenderedServicePath> getRenderedServicePath(String rspName) {
- RenderedServicePathKey renderedServicePathKey = new RenderedServicePathKey(new RspName(rspName));
- InstanceIdentifier<RenderedServicePath> rspIid = InstanceIdentifier.builder(RenderedServicePaths.class)
- .child(RenderedServicePath.class, renderedServicePathKey).build();
-
-
- return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, rspIid).toJavaUtil();
- }
-
- public Optional<RenderedServicePath> getRenderedServicePathFromSfc(String sfcName) {
- Optional<RenderedServicePath> rsp = Optional.empty();
-
- // TODO need to finish this
-
- return rsp;
- }
-
- public Optional<List<String>> readServicePathState(String sfpName) {
- ServiceFunctionPathStateKey serviceFunctionPathStateKey = new ServiceFunctionPathStateKey(new SfpName(sfpName));
- InstanceIdentifier<ServiceFunctionPathState> sfpIiD;
- sfpIiD = InstanceIdentifier.builder(ServiceFunctionPathsState.class)
- .child(ServiceFunctionPathState.class, serviceFunctionPathStateKey)
- .build();
- return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, sfpIiD)
- .toJavaUtil()
- .map(ServiceFunctionPathState::getSfpRenderedServicePath)
- .map(sfpRenderedServicePaths -> sfpRenderedServicePaths.stream()
- .map(sfpRenderedServicePath -> sfpRenderedServicePath.getName().getValue())
- .collect(Collectors.toList()));
- }
-
- public Optional<String> getFirstHopIngressInterfaceFromRsp(RenderedServicePath rsp) {
- // The ingres interface on the first hop is specified in the forward DPL
- // in a forward path or the reverse DPL otherwise
- boolean useForwardDpl = !rsp.isReversePath();
- return getRspFirstHop(rsp).flatMap(rspHop -> getHopSfInterface(rspHop, useForwardDpl));
- }
-
- public Optional<String> getLastHopEgressInterfaceFromRsp(RenderedServicePath rsp) {
- // The egress interface on the first hop is specified in the forward DPL
- // in a forward path or the reverse DPL otherwise
- boolean useForwardDpl = rsp.isReversePath();
- return getRspLastHop(rsp).flatMap(rspHop -> getHopSfInterface(rspHop, useForwardDpl));
- }
-
- private Optional<String> getHopSfInterface(RenderedServicePathHop hop, boolean useForwardDpl) {
-
- LOG.trace("getHopSfInterface of hop {}", hop);
-
- SfName sfName = hop.getServiceFunctionName();
- if (sfName == null) {
- LOG.warn("getHopSfInterface hop has no SF");
- return Optional.empty();
- }
-
- SffName sffName = hop.getServiceFunctionForwarder();
- if (sffName == null) {
- LOG.warn("getHopSfInterface hop has no SFF");
- return Optional.empty();
- }
-
- Optional<ServiceFunctionForwarder> sff = getServiceFunctionForwarder(sffName);
- if (!sff.isPresent()) {
- LOG.warn("getHopSfInterface SFF [{}] does not exist", sffName.getValue());
- return Optional.empty();
- }
-
- // Find the SFF-SF data plane locator for the SF pair
- SffSfDataPlaneLocator sffSfDataPlaneLocator = sff.map(ServiceFunctionForwarder::getServiceFunctionDictionary)
- .orElse(Collections.emptyList())
- .stream()
- .filter(serviceFunctionDictionary -> Objects.equals(serviceFunctionDictionary.getName(), sfName))
- .findAny()
- .map(ServiceFunctionDictionary::getSffSfDataPlaneLocator)
- .orElse(null);
-
- if (sffSfDataPlaneLocator == null) {
- LOG.warn("getHopSfInterface SFF [{}] has not dictionary for SF [{}]",
- sffName.getValue(),
- sffName.getValue());
- return Optional.empty();
- }
-
- // Get the forward or reverse locator name as appropriate if any,
- // otherwise default to non directional locator
- SffDataPlaneLocatorName sffDataPlaneLocatorName = null;
- if (useForwardDpl) {
- sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffForwardDplName();
- } else {
- sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffReverseDplName();
- }
- if (sffDataPlaneLocatorName == null) {
- sffDataPlaneLocatorName = sffSfDataPlaneLocator.getSffDplName();
- }
-
- // Get the interface name value of the locator with such name
- SffDataPlaneLocatorName locatorName = sffDataPlaneLocatorName;
- Optional<String> interfaceName = sff.map(ServiceFunctionForwarderBase::getSffDataPlaneLocator)
- .orElse(Collections.emptyList())
- .stream()
- .filter(sffDataPlaneLocator -> Objects.equals(sffDataPlaneLocator.getName(), locatorName))
- .findAny()
- .map(SffDataPlaneLocator::getDataPlaneLocator)
- .filter(dataPlaneLocator -> dataPlaneLocator.getLocatorType() instanceof LogicalInterface)
- .map(dataPlaneLocator -> (LogicalInterfaceLocator) dataPlaneLocator.getLocatorType())
- .map(LogicalInterfaceLocator::getInterfaceName);
-
- return interfaceName;
- }
-
- private Optional<ServiceFunctionForwarder> getServiceFunctionForwarder(SffName name) {
- ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(name);
- InstanceIdentifier<ServiceFunctionForwarder> sffIid;
- sffIid = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
- .child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey)
- .build();
-
- return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, sffIid).toJavaUtil();
- }
-
- private Optional<RenderedServicePathHop> getRspFirstHop(RenderedServicePath rsp) {
- List<RenderedServicePathHop> hops = rsp.getRenderedServicePathHop();
- if (hops == null || hops.isEmpty()) {
- LOG.warn("getRspFirstHop RSP [{}] has no hops list", rsp.getName().getValue());
- return Optional.empty();
- }
-
- return Optional.ofNullable(hops.get(0));
- }
-
- private Optional<RenderedServicePathHop> getRspLastHop(RenderedServicePath rsp) {
- List<RenderedServicePathHop> hops = rsp.getRenderedServicePathHop();
- if (hops == null || hops.isEmpty()) {
- LOG.warn("getRspLastHop RSP [{}] has no hops list", rsp.getName().getValue());
- return Optional.empty();
- }
-
- return Optional.ofNullable(hops.get(hops.size() - 1));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Executor;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.infrautils.utils.concurrent.Executors;
-import org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider;
-import org.opendaylight.netvirt.sfc.classifier.providers.NetvirtProvider;
-import org.opendaylight.netvirt.sfc.classifier.providers.OpenFlow13Provider;
-import org.opendaylight.netvirt.sfc.classifier.providers.SfcProvider;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierState;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.impl.ClassifierUpdate;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.impl.ConfigurationClassifierImpl;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.impl.GeniusRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.impl.OpenflowRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.impl.OperationalClassifierImpl;
-import org.opendaylight.netvirt.sfc.classifier.utils.LastTaskExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class ClassifierService {
-
- private final NetvirtProvider netvirtProvider;
- private final GeniusProvider geniusProvider;
- private final SfcProvider sfcProvider;
- private final DataBroker dataBroker;
- private final Executor lastTaskExecutor;
- private final OperationalClassifierImpl operationalClassifier = new OperationalClassifierImpl();
- private final List<ClassifierEntryRenderer> classifierRenderers = new ArrayList<>();
- private static final Logger LOG = LoggerFactory.getLogger(ClassifierService.class);
-
- @Inject
- public ClassifierService(final NetvirtProvider netvirtProvider, final GeniusProvider geniusProvider,
- final SfcProvider sfcProvider, final OpenFlow13Provider openFlow13Provider,
- final DataBroker dataBroker) {
- this.netvirtProvider = netvirtProvider;
- this.geniusProvider = geniusProvider;
- this.sfcProvider = sfcProvider;
- this.dataBroker = dataBroker;
- this.lastTaskExecutor = new LastTaskExecutor(
- Executors.newSingleThreadExecutor(getClass().getSimpleName(), LOG));
- classifierRenderers.add(new OpenflowRenderer(openFlow13Provider, geniusProvider, dataBroker));
- classifierRenderers.add(new GeniusRenderer(geniusProvider));
- classifierRenderers.add(operationalClassifier.getRenderer());
- }
-
- public void updateAll() {
- lastTaskExecutor.execute(this::doUpdateAll);
- }
-
- private void doUpdateAll() {
-
- ClassifierState configurationClassifier = new ConfigurationClassifierImpl(
- geniusProvider,
- netvirtProvider,
- sfcProvider,
- dataBroker);
-
- ClassifierUpdate classifierUpdate = new ClassifierUpdate(
- configurationClassifier,
- operationalClassifier,
- classifierRenderers);
-
- classifierUpdate.run();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain;
-
-import com.google.common.base.MoreObjects;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-/**
- * A generic {@link ClassifierRenderableEntry} implementation that supports all
- * the different render types.
- */
-public final class ClassifierEntry implements ClassifierRenderableEntry {
-
- private enum EntryType {
- NODE_ENTRY_TYPE,
- INGRESS_INTERFACE_ENTRY_TYPE,
- PATH_ENTRY_TYPE,
- MATCH_ENTRY_TYPE,
- EGRESS_INTERFACE_ENTRY_TYPE
- }
-
- private final EntryType entryType;
- // TODO skitt Rework using a class hierarchy so we can enforce null constraints
- private final @Nullable NodeId node;
- private final @Nullable InterfaceKey interfaceKey;
- private final @Nullable String connector;
- private final @Nullable Matches matches;
- private final @Nullable Long nsp;
- private final @Nullable Short nsi;
- private final @Nullable Short nsl;
- private final @Nullable String destinationIp;
- private final @Nullable String firstHopIp;
-
- private ClassifierEntry(EntryType entryType, @Nullable NodeId node, @Nullable InterfaceKey interfaceKey,
- @Nullable String connector, @Nullable Matches matches, @Nullable Long nsp,
- @Nullable Short nsi, @Nullable Short nsl, @Nullable String destinationIp,
- @Nullable String firstHopIp) {
- this.entryType = entryType;
- this.node = node;
- this.interfaceKey = interfaceKey;
- this.connector = connector;
- this.matches = matches;
- this.nsp = nsp;
- this.nsi = nsi;
- this.nsl = nsl;
- this.destinationIp = destinationIp;
- this.firstHopIp = firstHopIp;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- entryType,
- node,
- interfaceKey,
- connector,
- matches,
- nsp,
- nsi,
- nsl,
- destinationIp,
- firstHopIp);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!ClassifierEntry.class.equals(obj.getClass())) {
- return false;
- }
- ClassifierEntry other = (ClassifierEntry) obj;
- return Objects.equals(entryType, other.entryType)
- && Objects.equals(node, other.node)
- && Objects.equals(interfaceKey, other.interfaceKey)
- && Objects.equals(connector, other.connector)
- && Objects.equals(matches, other.matches)
- && Objects.equals(nsp, other.nsp)
- && Objects.equals(nsi, other.nsi)
- && Objects.equals(destinationIp, other.destinationIp)
- && Objects.equals(nsl, other.nsl)
- && Objects.equals(firstHopIp, other.firstHopIp);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("entryType", entryType)
- .add("node", node)
- .add("interfaceKey", interfaceKey)
- .add("connector", connector)
- .add("matches", matches)
- .add("nsp", nsp)
- .add("nsi", nsi)
- .add("nsl", nsl)
- .add("destinationIp", destinationIp)
- .add("firstHopIp", firstHopIp)
- .toString();
- }
-
- @Override
- public void render(ClassifierEntryRenderer classifierEntryRenderer) {
- switch (entryType) {
- case NODE_ENTRY_TYPE:
- classifierEntryRenderer.renderNode(node);
- break;
- case INGRESS_INTERFACE_ENTRY_TYPE:
- classifierEntryRenderer.renderIngress(interfaceKey);
- break;
- case PATH_ENTRY_TYPE:
- classifierEntryRenderer.renderPath(node, nsp, nsi, nsl, firstHopIp);
- break;
- case MATCH_ENTRY_TYPE:
- classifierEntryRenderer.renderMatch(node, connector, matches, nsp, nsi);
- break;
- case EGRESS_INTERFACE_ENTRY_TYPE:
- classifierEntryRenderer.renderEgress(interfaceKey, destinationIp);
- break;
- default:
- }
- }
-
- @Override
- public void suppress(ClassifierEntryRenderer classifierEntryRenderer) {
- switch (entryType) {
- case NODE_ENTRY_TYPE:
- classifierEntryRenderer.suppressNode(node);
- break;
- case INGRESS_INTERFACE_ENTRY_TYPE:
- classifierEntryRenderer.suppressIngress(interfaceKey);
- break;
- case PATH_ENTRY_TYPE:
- classifierEntryRenderer.suppressPath(node, nsp, nsi, nsl, firstHopIp);
- break;
- case MATCH_ENTRY_TYPE:
- classifierEntryRenderer.suppressMatch(node, connector, matches, nsp, nsi);
- break;
- case EGRESS_INTERFACE_ENTRY_TYPE:
- classifierEntryRenderer.suppressEgress(interfaceKey, destinationIp);
- break;
- default:
- }
- }
-
- /**
- * Build a {@code ClassifierEntry} supporting an ingress render type.
- *
- * @param interfaceKey the ingress interface.
- * @return the {@code ClassifierEntry}.
- */
- public static ClassifierEntry buildIngressEntry(InterfaceKey interfaceKey) {
- return new ClassifierEntry(
- EntryType.INGRESS_INTERFACE_ENTRY_TYPE,
- null,
- interfaceKey,
- null,
- null,
- null,
- null,
- null,
- null,
- null);
- }
-
- /**
- * Build a {@code ClassifierEntry} supporting an node render type.
- *
- * @param node the classifier node identifier.
- * @return the {@code ClassifierEntry}.
- */
- public static ClassifierEntry buildNodeEntry(NodeId node) {
- return new ClassifierEntry(
- EntryType.NODE_ENTRY_TYPE,
- node,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null);
- }
-
- /**
- * Build a {@code ClassifierEntry} supporting a path render type.
- *
- * @param node the classifier node identifier.
- * @param nsp the path identifier.
- * @param nsi the path starting index.
- * @param nsl the path length.
- * @param firstHopIp the first SFF ip address. Null if the SFF is nodeId.
- * @return the {@code ClassifierEntry}.
- */
- public static ClassifierEntry buildPathEntry(NodeId node, Long nsp, short nsi, short nsl,
- @Nullable String firstHopIp) {
- return new ClassifierEntry(
- EntryType.PATH_ENTRY_TYPE,
- node,
- null,
- null,
- null,
- nsp,
- nsi,
- nsl,
- null,
- firstHopIp);
- }
-
- /**
- * Build a {@code ClassifierEntry} supporting an match render type.
- *
- * @param node the classifier node identifier.
- * @param connector the node connector for the ingress interface.
- * @param matches the ACL matches.
- * @param nsp the path identifier.
- * @param nsi the initial path index.
- * @return the {@code ClassifierEntry}.
- */
- public static ClassifierEntry buildMatchEntry(NodeId node, String connector, Matches matches, Long nsp, Short nsi) {
- return new ClassifierEntry(
- EntryType.MATCH_ENTRY_TYPE,
- node,
- null,
- connector,
- matches,
- nsp,
- nsi,
- null,
- null,
- null);
- }
-
- /**
- * Build a {@code ClassifierEntry} supporting a remote egress render type.
- *
- * @param interfaceKey the egress interface key.
- * @param destinationIp the destination IP address associated to the
- * interface. If the interface is a local interface,
- * this should be a node local IP address, otherwise
- * the remote IP address.
- * @return the {@code ClassifierEntry}.
- */
- public static ClassifierEntry buildEgressEntry(InterfaceKey interfaceKey, String destinationIp) {
- return new ClassifierEntry(
- EntryType.EGRESS_INTERFACE_ENTRY_TYPE,
- null,
- interfaceKey,
- null,
- null,
- null,
- null,
- null,
- destinationIp,
- null);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.api;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-/**
- * The interface of classifier entry renderers.
- *
- * <p>
- * There are different independent render types:
- * - Ingress (i.e. ingress bind to interface).
- * - Node (i.e. node initialization).
- * - Path (i.e. write path egress flows).
- * - Match (i.e. write ACL flow).
- * - Egress (i.e egress bind to interface).
- *
- * <p>
- * A renderer may not implement all the render types and is responsible to know
- * if the render applies to it or not (for example, an openflow renderer should
- * not write to a non openflow node).
- */
-public interface ClassifierEntryRenderer {
-
- /**
- * Render ingress interface actions.
- *
- * @param interfaceKey the ingress interface key.
- */
- void renderIngress(InterfaceKey interfaceKey);
-
- /**
- * Render node wide actions.
- *
- * @param nodeId the classifier node identifier.
- */
- void renderNode(NodeId nodeId);
-
- /**
- * Render path based actions.
- *
- * @param nodeId the classifier node identifier.
- * @param nsp the path identifier.
- * @param nsi the path starting index.
- * @param nsl the path length.
- * @param firstHopIp the first SFF ip address. Null if the SFF is nodeId.
- */
- void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp);
-
- /**
- * Rended match based actions.
- *
- * @param nodeId the classifier node identifier.
- * @param connector the node connector for the ingress interface.
- * @param matches the ACL matches.
- * @param nsp the path identifier.
- * @param nsi the initial path index.
- */
- void renderMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi);
-
- /**
- * Render egress interface actions.
- *
- * @param interfaceKey the egress interface key.
- * @param destinationIp the destination IP address associated to the
- * interface. If the interface is a local interface,
- * this should be a node local IP address, otherwise
- * the remote IP address.
- */
- void renderEgress(InterfaceKey interfaceKey, String destinationIp);
-
- /**
- * Suppress ingress interface actions.
- *
- * @param interfaceKey the ingress interface key.
- */
- void suppressIngress(InterfaceKey interfaceKey);
-
- /**
- * Suppress node wide actions.
- *
- * @param nodeId the classifier node identifier.
- */
- void suppressNode(NodeId nodeId);
-
- /**
- * Supress path based actions.
- *
- * @param nodeId the classifier node identifier.
- * @param nsp the path identifier.
- * @param nsi the path starting index.
- * @param nsl the path length.
- * @param firstHopIp the first SFF ip address. Null if the SFF is nodeId.
- */
- void suppressPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp);
-
- /**
- * Supress match based actions.
- *
- * @param nodeId the classifier node identifier.
- * @param connector the node connector for the ingress interface.
- * @param matches the ACL matches.
- * @param nsp the path identifier.
- * @param nsi the initial path index.
- */
- void suppressMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi);
-
- /**
- * Supress egress interface actions.
- *
- * @param interfaceKey the egress interface key.
- * @param destinationIp the destination IP address associated to the
- * interface. If the interface is a local interface,
- * this should be a node local IP address, otherwise
- * the remote IP address.
- */
- void suppressEgress(InterfaceKey interfaceKey, String destinationIp);
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.api;
-
-/**
- * A {@code ClassifierRenderableEntry} represents a unit of classifier
- * information that may be used to consistently perform ("render")
- * actions to southbound APIs that can also be consistently reversed
- * ("suppress").
- */
-public interface ClassifierRenderableEntry {
-
- /**
- * Render the entry using the provided {@code ClassifierEntryRenderer}.
- *
- * @param classifierEntryRenderer the renderer.
- */
- void render(ClassifierEntryRenderer classifierEntryRenderer);
-
- /**
- * Suppress the entry using the provided {@code ClassifierEntryRenderer}.
- *
- * @param classifierEntryRenderer the renderer.
- */
- void suppress(ClassifierEntryRenderer classifierEntryRenderer);
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.api;
-
-import java.util.Set;
-
-/**
- * The classifier state defined by a collection of {@link
- * ClassifierRenderableEntry}.
- */
-public interface ClassifierState {
- Set<ClassifierRenderableEntry> getAllEntries();
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import com.google.common.collect.Sets;
-import java.util.List;
-import java.util.Set;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ClassifierUpdate implements Runnable {
-
- private final ClassifierState configurationClassifier;
- private final ClassifierState operationalClassifier;
- private final List<ClassifierEntryRenderer> classifierRenderers;
- private static final Logger LOG = LoggerFactory.getLogger(ClassifierUpdate.class);
-
- public ClassifierUpdate(ClassifierState configurationClassifier, ClassifierState operationalClassifier,
- List<ClassifierEntryRenderer> classifierRenderers) {
- this.configurationClassifier = configurationClassifier;
- this.operationalClassifier = operationalClassifier;
- this.classifierRenderers = classifierRenderers;
- }
-
- @Override
- public void run() {
- Set<ClassifierRenderableEntry> configurationEntries = configurationClassifier.getAllEntries();
- Set<ClassifierRenderableEntry> operationalEntries = operationalClassifier.getAllEntries();
- Set<ClassifierRenderableEntry> entriesToAdd =
- Sets.difference(configurationEntries, operationalEntries).immutableCopy();
- Set<ClassifierRenderableEntry> entriesToRemove =
- Sets.difference(operationalEntries, configurationEntries).immutableCopy();
-
- LOG.trace("Configuration entries: {}", configurationEntries);
- LOG.trace("Operational entries: {}", operationalEntries);
- LOG.trace("Entries to add: {}", entriesToAdd);
- LOG.trace("Entries to remove: {}", entriesToRemove);
-
- classifierRenderers.forEach(
- classifierRenderer -> {
- entriesToRemove.forEach(classifierRenderableEntry ->
- classifierRenderableEntry.suppress(classifierRenderer));
- entriesToAdd.forEach(classifierRenderableEntry ->
- classifierRenderableEntry.render(classifierRenderer));
- });
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import com.google.common.base.Strings;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider;
-import org.opendaylight.netvirt.sfc.classifier.providers.NetvirtProvider;
-import org.opendaylight.netvirt.sfc.classifier.providers.OpenFlow13Provider;
-import org.opendaylight.netvirt.sfc.classifier.providers.SfcProvider;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.ClassifierEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierState;
-import org.opendaylight.netvirt.sfc.classifier.utils.AclMatches;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NetvirtsfcAclActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPorts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfc;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConfigurationClassifierImpl implements ClassifierState {
-
- private final SfcProvider sfcProvider;
- private final DataBroker dataBroker;
- private final GeniusProvider geniusProvider;
- private final NetvirtProvider netvirtProvider;
- private static final Logger LOG = LoggerFactory.getLogger(ConfigurationClassifierImpl.class);
- private static final String LOCAL_HOST_IP = "127.0.0.1";
-
- public ConfigurationClassifierImpl(GeniusProvider geniusProvider,
- NetvirtProvider netvirtProvider,
- SfcProvider sfcProvider,
- DataBroker dataBroker) {
- this.geniusProvider = geniusProvider;
- this.netvirtProvider = netvirtProvider;
- this.sfcProvider = sfcProvider;
- this.dataBroker = dataBroker;
- }
-
- @Override
- public Set<ClassifierRenderableEntry> getAllEntries() {
- return readAcls().stream()
- .map(Acl::getAccessListEntries)
- .filter(Objects::nonNull)
- .map(AccessListEntries::getAce)
- .filter(Objects::nonNull)
- .flatMap(List::stream)
- .map(this::getEntriesForAce)
- .flatMap(Set::stream)
- .collect(Collectors.toSet());
- }
-
- private List<Acl> readAcls() {
- InstanceIdentifier<AccessLists> aclsIID = InstanceIdentifier.builder(AccessLists.class).build();
- Optional<AccessLists> acls;
- acls = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, aclsIID).toJavaUtil();
- LOG.trace("Acls read from datastore: {}", acls);
- return acls.map(AccessLists::getAcl).orElse(Collections.emptyList());
- }
-
- private Set<ClassifierRenderableEntry> getEntriesForAce(Ace ace) {
- String ruleName = ace.getRuleName();
- LOG.debug("Generating classifier entries for Ace: {}", ruleName);
- LOG.trace("Ace details: {}", ace);
-
- Optional<NetvirtsfcAclActions> sfcActions = Optional.ofNullable(ace.getActions())
- .map(actions -> actions.augmentation(RedirectToSfc.class));
- String rspName = sfcActions.map(NetvirtsfcAclActions::getRspName).map(Strings::emptyToNull).orElse(null);
- String sfpName = sfcActions.map(NetvirtsfcAclActions::getSfpName).map(Strings::emptyToNull).orElse(null);
-
- if (rspName == null && sfpName == null) {
- LOG.debug("Ace {} ignored: no valid SFC redirect action", ruleName);
- return Collections.emptySet();
- }
- if (rspName != null && sfpName != null) {
- LOG.warn("Ace {} ignored: both SFP and a RSP as redirect actions not supported", ruleName);
- return Collections.emptySet();
- }
-
- Matches matches = ace.getMatches();
- if (matches == null) {
- LOG.warn("Ace {} ignored: no matches", ruleName);
- return Collections.emptySet();
- }
-
- NeutronNetwork network = matches.augmentation(NeutronNetwork.class);
- if (sfpName != null && network != null) {
- LOG.warn("Ace {} ignored: SFP redirect action with neutron network match not supported", ruleName);
- return Collections.emptySet();
- }
-
- String sourcePort = Optional.ofNullable(matches.augmentation(NeutronPorts.class))
- .map(NeutronPorts::getSourcePortUuid)
- .map(Strings::emptyToNull)
- .orElse(null);
- String destinationPort = Optional.ofNullable(matches.augmentation(NeutronPorts.class))
- .map(NeutronPorts::getDestinationPortUuid)
- .map(Strings::emptyToNull)
- .orElse(null);
-
- if (rspName != null) {
- return getEntriesForRspRedirect(ruleName, sourcePort, destinationPort, network, rspName, matches);
- }
-
- return getEntriesForSfpRedirect(ruleName, sourcePort, destinationPort, sfpName, matches);
- }
-
- private Set<ClassifierRenderableEntry> getEntriesForRspRedirect(
- String ruleName,
- String sourcePort,
- String destinationPort,
- NeutronNetwork neutronNetwork,
- String rspName,
- Matches matches) {
-
- RenderedServicePath rsp = sfcProvider.getRenderedServicePath(rspName).orElse(null);
- if (rsp == null) {
- LOG.debug("Ace {} ignored: RSP {} not yet available", ruleName, rspName);
- return Collections.emptySet();
- }
-
- if (destinationPort != null) {
- LOG.warn("Ace {}: destination port is ignored combined with RSP redirect", ruleName);
- }
-
- List<String> interfaces = new ArrayList<>();
- if (neutronNetwork != null) {
- interfaces.addAll(netvirtProvider.getLogicalInterfacesFromNeutronNetwork(neutronNetwork));
- }
- if (sourcePort != null) {
- interfaces.add(sourcePort);
- }
-
- if (interfaces.isEmpty()) {
- LOG.debug("Ace {} ignored: no interfaces to match against", ruleName);
- return Collections.emptySet();
- }
-
- return this.buildEntries(ruleName, interfaces, matches, rsp);
- }
-
- private Set<ClassifierRenderableEntry> getEntriesForSfpRedirect(
- String ruleName,
- String srcPort,
- String dstPort,
- String sfpName,
- Matches matches) {
-
- if (srcPort == null && dstPort == null) {
- LOG.warn("Ace {} ignored: no source or destination port to match against", ruleName);
- return Collections.emptySet();
- }
-
- if (Objects.equals(srcPort, dstPort)) {
- LOG.warn("Ace {} ignored: equal source and destination port not supported", ruleName);
- return Collections.emptySet();
- }
-
- List<RenderedServicePath> rsps = sfcProvider.readServicePathState(sfpName)
- .orElse(Collections.emptyList())
- .stream()
- .map(sfcProvider::getRenderedServicePath)
- .filter(Optional::isPresent)
- .map(Optional::get)
- .collect(Collectors.toList());
-
- // The classifier might be configured at the same time as the SFP.
- // The RSPs that are automatically added from that SFP might still
- // be missing. It will be handled on a later listener event.
- if (rsps.isEmpty()) {
- LOG.debug("Ace {} ignored: no RSPs for SFP {} yet available", ruleName, sfpName);
- return Collections.emptySet();
- }
-
- // An SFP will have two RSPs associated if symmetric, one otherwise.
- if (rsps.size() > 2) {
- LOG.warn("Ace {} ignored: more than two RSPs associated to SFP {} not supported", ruleName, sfpName);
- return Collections.emptySet();
- }
-
- RenderedServicePath forwardRsp = rsps.stream()
- .filter(rsp -> !rsp.isReversePath())
- .findAny()
- .orElse(null);
- RenderedServicePath reverseRsp = rsps.stream()
- .filter(RenderedServicePath::isReversePath)
- .filter(rsp -> forwardRsp != null && Objects.equals(rsp.getSymmetricPathId(), forwardRsp.getPathId()))
- .findAny()
- .orElse(null);
-
- if (srcPort != null && forwardRsp == null) {
- LOG.debug("Ace {} ignored: no forward RSP yet available for SFP {} and source port {}",
- ruleName, sfpName, srcPort);
- return Collections.emptySet();
- }
-
- if (dstPort != null && reverseRsp == null) {
- LOG.debug("Ace {} ignored: no reverse RSP yet available for SFP {} and destination port {}",
- ruleName, sfpName, dstPort);
- return Collections.emptySet();
- }
-
- Set<ClassifierRenderableEntry> entries = new HashSet<>();
- if (srcPort != null) {
- entries.addAll(this.buildEntries(ruleName, Collections.singletonList(srcPort), matches, forwardRsp));
- }
- if (dstPort != null) {
- Matches invertedMatches = AclMatches.invertMatches(matches);
- entries.addAll(
- this.buildEntries(ruleName, Collections.singletonList(dstPort), invertedMatches, reverseRsp));
- }
-
- return entries;
- }
-
- private Set<ClassifierRenderableEntry> buildEntries(
- String ruleName,
- @NonNull List<String> interfaces,
- @NonNull Matches matches,
- @NonNull RenderedServicePath rsp) {
-
- String rspName = rsp.getName().getValue();
- Long nsp = rsp.getPathId().longValue();
- Short nsi = rsp.getStartingIndex().shortValue();
- Short nsl = rsp.getRenderedServicePathHop() == null ? null : (short) rsp.getRenderedServicePathHop().size();
-
- if (nsp == null || nsi == null || nsl == null) {
- LOG.warn("Ace {} RSP {} ignored: no valid NSI or NSP or length", ruleName, rspName);
- return Collections.emptySet();
- }
-
- DpnIdType firstHopDpn = sfcProvider.getFirstHopIngressInterfaceFromRsp(rsp)
- .flatMap(geniusProvider::getDpnIdFromInterfaceName)
- .orElse(null);
-
- if (firstHopDpn == null) {
- LOG.warn("Ace {} RSP {} ignored: no valid first hop DPN", ruleName, rspName);
- return Collections.emptySet();
- }
-
- String lastHopInterface = sfcProvider.getLastHopEgressInterfaceFromRsp(rsp).orElse(null);
- if (lastHopInterface == null) {
- LOG.warn("Ace {} RSP {} ignored: has no valid last hop interface", ruleName, rspName);
- return Collections.emptySet();
- }
-
- DpnIdType lastHopDpn = geniusProvider.getDpnIdFromInterfaceName(lastHopInterface).orElse(null);
- if (lastHopDpn == null) {
- LOG.warn("Ace {} RSP {} ignored: has no valid last hop DPN", ruleName, rspName);
- return Collections.emptySet();
- }
-
- Map<NodeId, List<InterfaceKey>> nodeToInterfaces = new HashMap<>();
- for (String iface : interfaces) {
- geniusProvider.getNodeIdFromLogicalInterface(iface).ifPresent(nodeId ->
- nodeToInterfaces.computeIfAbsent(nodeId, key -> new ArrayList<>()).add(new InterfaceKey(iface)));
- }
-
- LOG.trace("Ace {} RSP {}: got classifier nodes and interfaces: {}", ruleName, rspName, nodeToInterfaces);
-
- String firstHopIp = geniusProvider.getIpFromDpnId(firstHopDpn).orElse(null);
- Set<ClassifierRenderableEntry> entries = new HashSet<>();
- nodeToInterfaces.forEach((nodeId, ifaces) -> {
- // Get node info
- DpnIdType nodeDpn = new DpnIdType(OpenFlow13Provider.getDpnIdFromNodeId(nodeId));
-
- if (firstHopIp == null && !nodeDpn.equals(firstHopDpn)) {
- LOG.warn("Ace {} RSP {} classifier {} ignored: no IP to reach first hop DPN {}",
- ruleName, rspName, nodeId, firstHopDpn);
- return;
- }
-
- // Add entries that are not based on ingress or egress interface
- entries.add(ClassifierEntry.buildNodeEntry(nodeId));
- entries.add(ClassifierEntry.buildPathEntry(
- nodeId,
- nsp,
- nsi,
- nsl,
- nodeDpn.equals(firstHopDpn) ? null : firstHopIp));
-
- // Add entries based on ingress interface
- ifaces.forEach(interfaceKey -> {
- entries.add(ClassifierEntry.buildIngressEntry(interfaceKey));
- entries.add(ClassifierEntry.buildMatchEntry(
- nodeId,
- geniusProvider.getNodeConnectorIdFromInterfaceName(interfaceKey.getName()).get(),
- matches,
- nsp,
- nsi));
- });
-
- // To handle chain egress when origin, last SF and destination are on the same node,
- // we need to bind to the SF interface so that SFC pipeline to classifier pipeline
- // hand-off can happen through the dispatcher table
- if (nodeDpn.equals(lastHopDpn)) {
- entries.add(ClassifierEntry.buildIngressEntry(new InterfaceKey(lastHopInterface)));
- }
-
- // Egress services must bind to egress ports. Since we dont know before-hand what
- // the egress ports will be, we will bind on all switch ports. If the packet
- // doesnt have NSH, it will be returned to the the egress dispatcher table.
- String nodeIp = geniusProvider.getIpFromDpnId(nodeDpn).orElse(LOCAL_HOST_IP);
- List<Interfaces> interfaceUuidStrList = geniusProvider.getInterfacesFromNode(nodeId);
- interfaceUuidStrList.forEach(interfaceUuidStr -> {
- InterfaceKey interfaceKey = new InterfaceKey(interfaceUuidStr.getInterfaceName());
- Optional<String> remoteIp = geniusProvider.getRemoteIpAddress(interfaceUuidStr.getInterfaceName());
- entries.add(ClassifierEntry.buildEgressEntry(interfaceKey, remoteIp.orElse(nodeIp)));
- });
- });
-
- return entries;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-public class GeniusRenderer implements ClassifierEntryRenderer {
-
- private final GeniusProvider geniusProvider;
-
- public GeniusRenderer(GeniusProvider geniusProvider) {
- this.geniusProvider = geniusProvider;
- }
-
- @Override
- public void renderIngress(InterfaceKey interfaceKey) {
- geniusProvider.bindPortOnIngressClassifier(interfaceKey.getName());
- }
-
- @Override
- public void renderNode(NodeId nodeId) {
- // noop
- }
-
- @Override
- public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
- // noop
- }
-
- @Override
- public void renderMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- // noop
- }
-
- @Override
- public void renderEgress(InterfaceKey interfaceKey, String destinationIp) {
- geniusProvider.bindPortOnEgressClassifier(interfaceKey.getName(), destinationIp);
- }
-
- @Override
- public void suppressIngress(InterfaceKey interfaceKey) {
- geniusProvider.unbindPortOnIngressClassifier(interfaceKey.getName());
- }
-
- @Override
- public void suppressNode(NodeId nodeId) {
- // noop
- }
-
- @Override
- public void suppressPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
- // noop
- }
-
- @Override
- public void suppressMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- // noop
- }
-
- @Override
- public void suppressEgress(InterfaceKey interfaceKey, String destinationIp) {
- geniusProvider.unbindPortOnEgressClassifier(interfaceKey.getName());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
-import org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider;
-import org.opendaylight.netvirt.sfc.classifier.providers.OpenFlow13Provider;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OpenflowRenderer implements ClassifierEntryRenderer {
-
- private static final Logger LOG = LoggerFactory.getLogger(OpenflowRenderer.class);
-
- private final OpenFlow13Provider openFlow13Provider;
- private final GeniusProvider geniusProvider;
- private final ManagedNewTransactionRunner txRunner;
-
- public OpenflowRenderer(OpenFlow13Provider openFlow13Provider, GeniusProvider geniusProvider,
- DataBroker dataBroker) {
- this.openFlow13Provider = openFlow13Provider;
- this.geniusProvider = geniusProvider;
- this.txRunner = new ManagedNewTransactionRunnerImpl(dataBroker);
- }
-
- @Override
- public void renderIngress(InterfaceKey interfaceKey) {
- // noop
- }
-
- @Override
- // FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
- @SuppressFBWarnings("UC_USELESS_OBJECT")
- public void renderNode(NodeId nodeId) {
- List<Flow> flows = new ArrayList<>();
- flows.add(this.openFlow13Provider.createIngressClassifierFilterTunnelNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterEthNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterNoNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierAclNoMatchFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createIngressClassifierTunnelEthNshTrafficCaptureFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierTunnelNshTrafficCaptureFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createEgressClassifierFilterNoNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createEgressClassifierFilterNshFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createEgressClassifierNextHopFlow(nodeId));
-
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx))), LOG,
- "Error rendering node");
- }
-
- @Override
- // FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
- @SuppressFBWarnings("UC_USELESS_OBJECT")
- public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
-
- List<Flow> flows = new ArrayList<>();
- if (firstHopIp != null) {
- Long port = geniusProvider.getEgressVxlanPortForNode(OpenFlow13Provider.getDpnIdFromNodeId(nodeId))
- .orElse(null);
- if (port == null) {
- LOG.error("OpenflowRenderer: cant get egressPort for nodeId [{}]", nodeId.getValue());
- return;
- }
- Flow flow;
- flow = openFlow13Provider.createEgressClassifierTransportEgressRemoteEthNshFlow(
- nodeId, nsp, port, firstHopIp);
- flows.add(flow);
- } else {
- Flow flow;
- flow = openFlow13Provider.createEgressClassifierTransportEgressLocalFlow(nodeId, nsp);
- flows.add(flow);
- }
- short egressNsi = (short) (nsi - nsl);
- flows.add(openFlow13Provider.createIngressClassifierFilterChainEgressFlow(nodeId, nsp, egressNsi));
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx))), LOG,
- "Error rendering a path");
- }
-
- @Override
- public void renderMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- Long port = OpenFlow13Provider.getPortNoFromNodeConnector(connector);
- List<MatchBuilder> matchBuilds = this.openFlow13Provider.getMatchBuilderFromAceMatches(matches);
- for (MatchBuilder match : matchBuilds) {
- Flow flow = this.openFlow13Provider.createIngressClassifierAclFlow(nodeId, match, port, nsp, nsi);
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx)), LOG, "Error rendering a match");
- }
- }
-
- @Override
- public void renderEgress(InterfaceKey interfaceKey, String destinationIp) {
- // noop
- }
-
- @Override
- public void suppressIngress(InterfaceKey interfaceKey) {
- // noop
- }
-
- @Override
- // FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
- @SuppressFBWarnings("UC_USELESS_OBJECT")
- public void suppressNode(NodeId nodeId) {
- List<Flow> flows = new ArrayList<>();
- flows.add(this.openFlow13Provider.createIngressClassifierFilterTunnelNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterEthNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierFilterNoNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierAclNoMatchFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createIngressClassifierTunnelEthNshTrafficCaptureFlow(nodeId));
- flows.add(this.openFlow13Provider.createIngressClassifierTunnelNshTrafficCaptureFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createEgressClassifierFilterNoNshFlow(nodeId));
- flows.add(this.openFlow13Provider.createEgressClassifierFilterNshFlow(nodeId));
-
- flows.add(this.openFlow13Provider.createEgressClassifierNextHopFlow(nodeId));
-
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForDelete(nodeId, flow, tx))), LOG,
- "Error deleting a node");
- }
-
- @Override
- // FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
- @SuppressFBWarnings("UC_USELESS_OBJECT")
- public void suppressPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
- List<Flow> flows = new ArrayList<>();
- if (firstHopIp != null) {
- Long port = geniusProvider.getEgressVxlanPortForNode(OpenFlow13Provider.getDpnIdFromNodeId(nodeId))
- .orElse(null);
- if (port == null) {
- LOG.error("OpenflowRenderer: cant get egressPort for nodeId [{}]", nodeId.getValue());
- return;
- }
- Flow flow;
- flow = openFlow13Provider.createEgressClassifierTransportEgressRemoteEthNshFlow(
- nodeId, nsp, port, firstHopIp);
- flows.add(flow);
- } else {
- Flow flow;
- flow = openFlow13Provider.createEgressClassifierTransportEgressLocalFlow(nodeId, nsp);
- flows.add(flow);
- }
- short egressNsi = (short) (nsi - nsl);
- flows.add(openFlow13Provider.createIngressClassifierFilterChainEgressFlow(nodeId, nsp, egressNsi));
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForDelete(nodeId, flow, tx))), LOG,
- "Error deleting a path");
- }
-
- @Override
- public void suppressMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- Long port = OpenFlow13Provider.getPortNoFromNodeConnector(connector);
- List<MatchBuilder> matchBuilds = this.openFlow13Provider.getMatchBuilderFromAceMatches(matches);
- for (MatchBuilder match : matchBuilds) {
- Flow flow = this.openFlow13Provider.createIngressClassifierAclFlow(nodeId, match, port, nsp, nsi);
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
- tx -> this.openFlow13Provider.appendFlowForDelete(nodeId, flow, tx)), LOG, "Error deleting a match");
- }
- }
-
- @Override
- public void suppressEgress(InterfaceKey interfaceKey, String destinationIp) {
- // noop
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.ClassifierEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-public class OperationalClassifierImpl implements ClassifierState {
-
- private final Set<ClassifierRenderableEntry> entries = ConcurrentHashMap.newKeySet();
-
- @Override
- public Set<ClassifierRenderableEntry> getAllEntries() {
- return Collections.unmodifiableSet(entries);
- }
-
- public ClassifierEntryRenderer getRenderer() {
- return new ClassifierEntryRenderer() {
-
- @Override
- public void renderIngress(InterfaceKey interfaceKey) {
- entries.add(ClassifierEntry.buildIngressEntry(new InterfaceKey(interfaceKey)));
- }
-
- @Override
- public void renderNode(NodeId nodeId) {
- entries.add(ClassifierEntry.buildNodeEntry(nodeId));
- }
-
- @Override
- public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
- entries.add(ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, firstHopIp));
- }
-
- @Override
- public void renderMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- entries.add(ClassifierEntry.buildMatchEntry(nodeId, connector, matches, nsp, nsi));
- }
-
- @Override
- public void renderEgress(InterfaceKey interfaceKey, String destinationIp) {
- entries.add(ClassifierEntry.buildEgressEntry(interfaceKey, destinationIp));
- }
-
- @Override
- public void suppressIngress(InterfaceKey interfaceKey) {
- entries.remove(ClassifierEntry.buildIngressEntry(new InterfaceKey(interfaceKey)));
- }
-
- @Override
- public void suppressNode(NodeId nodeId) {
- entries.remove(ClassifierEntry.buildNodeEntry(nodeId));
- }
-
- @Override
- public void suppressPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
- entries.remove(ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, firstHopIp));
- }
-
- @Override
- public void suppressMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
- entries.remove(ClassifierEntry.buildMatchEntry(nodeId, connector, matches, nsp, nsi));
- }
-
- @Override
- public void suppressEgress(InterfaceKey interfaceKey, String destinationIp) {
- entries.remove(ClassifierEntry.buildEgressEntry(interfaceKey, destinationIp));
- }
- };
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2016 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import com.google.common.collect.Sets;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.genius.mdsalutil.packet.IPProtocols;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEthBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRange;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRange;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpDstKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpSrcKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.dst.grouping.NxmOfTcpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.src.grouping.NxmOfTcpSrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.dst.grouping.NxmOfUdpDstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrcBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AclMatches {
- private static final Logger LOG = LoggerFactory.getLogger(AclMatches.class);
- private MatchBuilder matchBuilder;
- private List<GeneralAugMatchNodesNodeTableFlow> portMatches;
- private final Matches matches;
- private boolean ipv4EtherTypeSet;
- private boolean ipv6EtherTypeSet;
-
- public AclMatches(Matches matches) {
- this.matches = matches;
- this.ipv4EtherTypeSet = false;
- this.ipv6EtherTypeSet = false;
- }
-
- /**
- * Convert the ACL into an OpenFlow {@link MatchBuilder}.
- * @return {@link MatchBuilder}
- */
- public List<MatchBuilder> buildMatch() {
- matchBuilder = new MatchBuilder();
- portMatches = new ArrayList<>();
- List<MatchBuilder> newMatches = new ArrayList<>();
- if (matches.getAceType() instanceof AceEth) {
- addEthMatch();
- } else if (matches.getAceType() instanceof AceIp) {
- addIpMatch();
- }
- if (portMatches.isEmpty()) {
- newMatches.add(this.matchBuilder);
- } else {
- for (GeneralAugMatchNodesNodeTableFlow portMatch : portMatches) {
- newMatches.add(new MatchBuilder(matchBuilder.build())
- .addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, portMatch));
- }
- }
- LOG.debug("returned matches: {}", newMatches);
- return newMatches;
- }
-
- private void addEthMatch() {
- AceEth aceEth = (AceEth) matches.getAceType();
-
- if (aceEth.getSourceMacAddress() != null) {
- EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
- EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
- ethSourceBuilder.setAddress(new MacAddress(aceEth.getSourceMacAddress()));
- ethernetMatch.setEthernetSource(ethSourceBuilder.build());
-
- matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
- }
-
- if (aceEth.getDestinationMacAddress() != null) {
- EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
- EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
- ethDestBuilder.setAddress(new MacAddress(aceEth.getDestinationMacAddress()));
- ethernetMatch.setEthernetDestination(ethDestBuilder.build());
-
- matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
- }
- }
-
- private void addIpMatch() {
- AceIp aceIp = (AceIp)matches.getAceType();
-
- if (aceIp.getDscp() != null) {
- addDscpMatch(aceIp);
- }
-
- if (aceIp.getProtocol() != null) {
- addIpProtocolMatch(aceIp);
- }
-
- if (aceIp.getAceIpVersion() instanceof AceIpv4) {
- addIpV4Match(aceIp);
- }
-
- if (aceIp.getAceIpVersion() instanceof AceIpv6) {
- addIpV6Match(aceIp);
- }
- }
-
- private void addDscpMatch(AceIp aceIp) {
- setIpv4EtherType();
-
- IpMatchBuilder ipMatch = new IpMatchBuilder();
- Dscp dscp = new Dscp(aceIp.getDscp());
- ipMatch.setIpDscp(dscp);
-
- matchBuilder.setIpMatch(mergeIpMatch(matchBuilder, ipMatch));
- }
-
- private void addIpProtocolMatch(AceIp aceIp) {
- // Match on IP
- setIpv4EtherType();
- IpMatchBuilder ipMatch = new IpMatchBuilder();
- ipMatch.setIpProtocol(aceIp.getProtocol());
- matchBuilder.setIpMatch(mergeIpMatch(matchBuilder, ipMatch));
-
- Integer srcPort = null;
- if (aceIp.getSourcePortRange() != null && aceIp.getSourcePortRange().getLowerPort() != null) {
- srcPort = aceIp.getSourcePortRange().getLowerPort().getValue().toJava();
- }
-
- Integer srcPortMax = srcPort;
- if (aceIp.getSourcePortRange() != null && aceIp.getSourcePortRange().getUpperPort() != null) {
- srcPortMax = aceIp.getSourcePortRange().getUpperPort().getValue().toJava();
- }
-
- Integer dstPort = null;
- if (aceIp.getDestinationPortRange() != null && aceIp.getDestinationPortRange().getLowerPort() != null) {
- dstPort = aceIp.getDestinationPortRange().getLowerPort().getValue().toJava();
- }
-
- Integer dstPortMax = dstPort;
- if (aceIp.getDestinationPortRange() != null && aceIp.getDestinationPortRange().getUpperPort() != null) {
- dstPortMax = aceIp.getDestinationPortRange().getUpperPort().getValue().toJava();
- }
-
- // Match on a TCP/UDP src/dst port
- if (srcPort != null || dstPort != null) {
- Map<Integer,Integer> srcPortMaskMap = srcPort == null ? Collections.singletonMap(0, 0) :
- getLayer4MaskForRange(srcPort, srcPortMax);
- Map<Integer,Integer> dstPortMaskMap = dstPort == null ? Collections.singletonMap(0, 0) :
- getLayer4MaskForRange(dstPort, dstPortMax);
- Set<List<Map.Entry<Integer,Integer>>> srcDstMatches = Sets
- .cartesianProduct(srcPortMaskMap.entrySet(), dstPortMaskMap.entrySet());
- if (aceIp.getProtocol().shortValue() == IPProtocols.TCP.shortValue()) {
- portMatches = srcDstMatches.stream().map(srcDstPairList -> buildTcpMatch(srcDstPairList
- .get(0), srcDstPairList.get(1))).collect(Collectors.toList());
- } else if (aceIp.getProtocol().shortValue() == IPProtocols.UDP.shortValue()) {
- portMatches = srcDstMatches.stream().map(srcDstPairList -> buildUdpMatch(srcDstPairList
- .get(0), srcDstPairList.get(1))).collect(Collectors.toList());
- }
- }
- }
-
- private static GeneralAugMatchNodesNodeTableFlow buildTcpMatch(Map.Entry<Integer,Integer> srcEntry,
- Map.Entry<Integer,Integer> dstEntry) {
- List<ExtensionList> srcDstExtList = new ArrayList<>();
-
- if (srcEntry.getValue() != 0) {
- NxmOfTcpSrcBuilder tcpSrc = new NxmOfTcpSrcBuilder();
- tcpSrc.setMask(srcEntry.getValue());
- tcpSrc.setPort(new PortNumber(srcEntry.getKey()));
- NxAugMatchNodesNodeTableFlow nxAugMatchTcpSrc =
- new NxAugMatchNodesNodeTableFlowBuilder().setNxmOfTcpSrc(tcpSrc.build()).build();
- srcDstExtList.add(new ExtensionListBuilder().setExtensionKey(NxmOfTcpSrcKey.class)
- .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class,
- nxAugMatchTcpSrc).build()).build());
- }
-
- if (dstEntry.getValue() != 0) {
- NxmOfTcpDstBuilder tcpDst = new NxmOfTcpDstBuilder();
- tcpDst.setMask(dstEntry.getValue());
- tcpDst.setPort(new PortNumber(dstEntry.getKey()));
- NxAugMatchNodesNodeTableFlow nxAugMatchTcpDst =
- new NxAugMatchNodesNodeTableFlowBuilder().setNxmOfTcpDst(tcpDst.build()).build();
- srcDstExtList.add(new ExtensionListBuilder().setExtensionKey(NxmOfTcpDstKey.class)
- .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class,
- nxAugMatchTcpDst).build()).build());
- }
-
- GeneralAugMatchNodesNodeTableFlow genAugMatch =
- new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(srcDstExtList).build();
-
- return genAugMatch;
- }
-
- private static GeneralAugMatchNodesNodeTableFlow buildUdpMatch(Map.Entry<Integer,Integer> srcEntry,
- Map.Entry<Integer,Integer> dstEntry) {
- List<ExtensionList> srcDstExtList = new ArrayList<>();
-
- if (srcEntry.getValue() != 0) {
- NxmOfUdpSrcBuilder udpSrc = new NxmOfUdpSrcBuilder();
- udpSrc.setMask(srcEntry.getValue());
- udpSrc.setPort(new PortNumber(srcEntry.getKey()));
- NxAugMatchNodesNodeTableFlow nxAugMatchUdpSrc =
- new NxAugMatchNodesNodeTableFlowBuilder().setNxmOfUdpSrc(udpSrc.build()).build();
- srcDstExtList.add(new ExtensionListBuilder().setExtensionKey(NxmOfUdpSrcKey.class)
- .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class,
- nxAugMatchUdpSrc).build()).build());
- }
-
- if (dstEntry.getValue() != 0) {
- NxmOfUdpDstBuilder udpDst = new NxmOfUdpDstBuilder();
- udpDst.setMask(dstEntry.getValue());
- udpDst.setPort(new PortNumber(dstEntry.getKey()));
- NxAugMatchNodesNodeTableFlow nxAugMatchUdpDst =
- new NxAugMatchNodesNodeTableFlowBuilder().setNxmOfUdpDst(udpDst.build()).build();
- srcDstExtList.add(new ExtensionListBuilder().setExtensionKey(NxmOfUdpDstKey.class)
- .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class,
- nxAugMatchUdpDst).build()).build());
- }
-
- GeneralAugMatchNodesNodeTableFlow genAugMatch =
- new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(srcDstExtList).build();
-
- return genAugMatch;
- }
-
- public static Map<Integer,Integer> getLayer4MaskForRange(int portMin, int portMax) {
- final int[] offset = { 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
- final int[] mask = { 0x8000, 0xC000, 0xE000, 0xF000, 0xF800, 0xFC00, 0xFE00, 0xFF00, 0xFF80, 0xFFC0, 0xFFE0,
- 0xFFF0, 0xFFF8, 0xFFFC, 0xFFFE, 0xFFFF };
- int noOfPorts = portMax - portMin + 1;
- Map<Integer,Integer> portMap = new HashMap<>();
- if (noOfPorts == 1) {
- portMap.put(portMin, mask[15]);
- return portMap;
- } else if (noOfPorts == 65535) {
- portMap.put(portMin, 0x0000);
- return portMap;
- }
- if (noOfPorts < 0) { // TODO: replace with infrautils.counter in case of high repetitive usage
- LOG.warn("Cannot convert port range into a set of masked port ranges - Illegal port range {}-{}", portMin,
- portMax);
- return portMap;
- }
- String binaryNoOfPorts = Integer.toBinaryString(noOfPorts);
- if (binaryNoOfPorts.length() > 16) { // TODO: replace with infrautils.counter in case of high repetitive usage
- LOG.warn("Cannot convert port range into a set of masked port ranges - Illegal port range {}-{}", portMin,
- portMax);
- return portMap;
- }
- int medianOffset = 16 - binaryNoOfPorts.length();
- int medianLength = offset[medianOffset];
- int median = 0;
- for (int tempMedian = 0;tempMedian < portMax;) {
- tempMedian = medianLength + tempMedian;
- if (portMin < tempMedian) {
- median = tempMedian;
- break;
- }
- }
- int tempMedian = 0;
- int currentMedain = median;
- for (int tempMedianOffset = medianOffset;16 > tempMedianOffset;tempMedianOffset++) {
- tempMedian = currentMedain - offset[tempMedianOffset];
- for (;portMin <= tempMedian;) {
- portMap.put(tempMedian, mask[tempMedianOffset]);
- currentMedain = tempMedian;
- tempMedian = tempMedian - offset[tempMedianOffset];
- }
- }
- currentMedain = median;
- for (int tempMedianOffset = medianOffset;16 > tempMedianOffset;tempMedianOffset++) {
- tempMedian = currentMedain + offset[tempMedianOffset];
- for (;portMax >= tempMedian - 1;) {
- portMap.put(currentMedain, mask[tempMedianOffset]);
- currentMedain = tempMedian;
- tempMedian = tempMedian + offset[tempMedianOffset];
- }
- }
- return portMap;
- }
-
- private void addIpV4Match(AceIp aceIp) {
- setIpv4EtherType();
-
- AceIpv4 aceIpv4 = (AceIpv4)aceIp.getAceIpVersion();
- if (aceIpv4.getDestinationIpv4Network() != null) {
- Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
- ipv4match.setIpv4Destination(aceIpv4.getDestinationIpv4Network());
- matchBuilder.setLayer3Match(mergeIpv4Match(matchBuilder, ipv4match));
- }
-
- if (aceIpv4.getSourceIpv4Network() != null) {
- Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
- ipv4match.setIpv4Source(aceIpv4.getSourceIpv4Network());
- matchBuilder.setLayer3Match(mergeIpv4Match(matchBuilder, ipv4match));
- }
- }
-
- private void addIpV6Match(AceIp aceIp) {
- setIpv6EtherType();
-
- AceIpv6 aceIpv6 = (AceIpv6)aceIp.getAceIpVersion();
- if (aceIpv6.getSourceIpv6Network() != null) {
- Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
- ipv6match.setIpv6Source(aceIpv6.getSourceIpv6Network());
- matchBuilder.setLayer3Match(mergeIpv6Match(matchBuilder, ipv6match));
- }
-
- if (aceIpv6.getDestinationIpv6Network() != null) {
- Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
- ipv6match.setIpv6Destination(aceIpv6.getDestinationIpv6Network());
- matchBuilder.setLayer3Match(mergeIpv6Match(matchBuilder, ipv6match));
- }
- }
-
- // If we call multiple Layer3 match methods, the MatchBuilder
- // Ipv4Match object gets overwritten each time, when we actually
- // want to set additional fields on the existing Ipv4Match object
- private static Ipv4Match mergeIpv4Match(MatchBuilder match, Ipv4MatchBuilder ipMatchBuilder) {
- Ipv4Match ipv4Match = (Ipv4Match) match.getLayer3Match();
- if (ipv4Match == null) {
- return ipMatchBuilder.build();
- }
-
- if (ipv4Match.getIpv4Destination() != null) {
- ipMatchBuilder.setIpv4Destination(ipv4Match.getIpv4Destination());
- }
-
- if (ipv4Match.getIpv4Source() != null) {
- ipMatchBuilder.setIpv4Source(ipv4Match.getIpv4Source());
- }
-
- return ipMatchBuilder.build();
- }
-
- private void setIpv6EtherType() {
- if (this.ipv6EtherTypeSet) {
- // No need to set it twice
- return;
- }
-
- setEtherType(NwConstants.ETHTYPE_IPV6);
- this.ipv6EtherTypeSet = true;
- }
-
- private void setIpv4EtherType() {
- if (this.ipv4EtherTypeSet) {
- // No need to set it twice
- return;
- }
-
- setEtherType(NwConstants.ETHTYPE_IPV4);
- this.ipv4EtherTypeSet = true;
- }
-
- private void setEtherType(long etherType) {
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
- ethTypeBuilder.setType(new EtherType(etherType));
- EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
- ethernetMatch.setEthernetType(ethTypeBuilder.build());
- matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
- }
-
- // If we call multiple Layer3 match methods, the MatchBuilder
- // Ipv6Match object gets overwritten each time, when we actually
- // want to set additional fields on the existing Ipv6Match object
- private static Ipv6Match mergeIpv6Match(MatchBuilder match, Ipv6MatchBuilder ipMatchBuilder) {
- Ipv6Match ipv6Match = (Ipv6Match) match.getLayer3Match();
- if (ipv6Match == null) {
- return ipMatchBuilder.build();
- }
-
- if (ipv6Match.getIpv6Destination() != null) {
- ipMatchBuilder.setIpv6Destination(ipv6Match.getIpv6Destination());
- }
-
- if (ipv6Match.getIpv6Source() != null) {
- ipMatchBuilder.setIpv6Source(ipv6Match.getIpv6Source());
- }
-
- return ipMatchBuilder.build();
- }
-
- // If we call multiple IpMatch match methods, the MatchBuilder
- // IpMatch object gets overwritten each time, when we actually
- // want to set additional fields on the existing IpMatch object
- private static IpMatch mergeIpMatch(MatchBuilder match, IpMatchBuilder ipMatchBuilder) {
- IpMatch ipMatch = match.getIpMatch();
- if (ipMatch == null) {
- return ipMatchBuilder.build();
- }
-
- if (ipMatch.getIpDscp() != null) {
- ipMatchBuilder.setIpDscp(ipMatch.getIpDscp());
- }
-
- if (ipMatch.getIpEcn() != null) {
- ipMatchBuilder.setIpEcn(ipMatch.getIpEcn());
- }
-
- if (ipMatch.getIpProto() != null) {
- ipMatchBuilder.setIpProto(ipMatch.getIpProto());
- }
-
- if (ipMatch.getIpProtocol() != null) {
- ipMatchBuilder.setIpProtocol(ipMatch.getIpProtocol());
- }
-
- return ipMatchBuilder.build();
- }
-
- // If we call multiple ethernet match methods, the MatchBuilder
- // EthernetMatch object gets overwritten each time, when we actually
- // want to set additional fields on the existing EthernetMatch object
- private static EthernetMatch mergeEthernetMatch(MatchBuilder match, EthernetMatchBuilder ethMatchBuilder) {
- EthernetMatch ethMatch = match.getEthernetMatch();
- if (ethMatch == null) {
- return ethMatchBuilder.build();
- }
-
- if (ethMatch.getEthernetDestination() != null) {
- ethMatchBuilder.setEthernetDestination(ethMatch.getEthernetDestination());
- }
-
- if (ethMatch.getEthernetSource() != null) {
- ethMatchBuilder.setEthernetSource(ethMatch.getEthernetSource());
- }
-
- if (ethMatch.getEthernetType() != null) {
- ethMatchBuilder.setEthernetType(ethMatch.getEthernetType());
- }
-
- return ethMatchBuilder.build();
- }
-
- public static Matches invertMatches(Matches matches) {
- LOG.trace("Invert matches: {}", matches);
- MatchesBuilder matchesBuilder = new MatchesBuilder(matches);
-
- if (matches.getAceType() instanceof AceIp) {
- AceIp aceIp = (AceIp) matches.getAceType();
- AceIpBuilder aceIpBuilder = new AceIpBuilder(aceIp);
- aceIpBuilder.setDestinationPortRange(null);
- aceIpBuilder.setSourcePortRange(null);
- SourcePortRange sourcePortRange = aceIp.getSourcePortRange();
- DestinationPortRange destinationPortRange = aceIp.getDestinationPortRange();
-
- if (sourcePortRange != null) {
- DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
- destinationPortRangeBuilder.setLowerPort(sourcePortRange.getLowerPort());
- destinationPortRangeBuilder.setUpperPort(sourcePortRange.getUpperPort());
- aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
- }
-
- if (destinationPortRange != null) {
- SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder();
- sourcePortRangeBuilder.setLowerPort(destinationPortRange.getLowerPort());
- sourcePortRangeBuilder.setUpperPort(destinationPortRange.getUpperPort());
- aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
- }
-
- if (aceIp.getAceIpVersion() instanceof AceIpv4) {
- AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
- Ipv4Prefix destinationIpv4Network = aceIpv4.getDestinationIpv4Network();
- Ipv4Prefix sourceIpv4Network = aceIpv4.getSourceIpv4Network();
-
- AceIpv4Builder aceIpv4Builder = new AceIpv4Builder(aceIpv4);
- aceIpv4Builder.setDestinationIpv4Network(sourceIpv4Network);
- aceIpv4Builder.setSourceIpv4Network(destinationIpv4Network);
- aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
-
- } else if (aceIp.getAceIpVersion() instanceof AceIpv6) {
- AceIpv6 aceIpv6 = (AceIpv6) aceIp.getAceIpVersion();
- Ipv6Prefix destinationIpv6Network = aceIpv6.getDestinationIpv6Network();
- Ipv6Prefix sourceIpv6Network = aceIpv6.getSourceIpv6Network();
-
- AceIpv6Builder aceIpv6Builder = new AceIpv6Builder(aceIpv6);
- aceIpv6Builder.setDestinationIpv6Network(sourceIpv6Network);
- aceIpv6Builder.setSourceIpv6Network(destinationIpv6Network);
- aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
- }
-
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- } else if (matches.getAceType() instanceof AceEth) {
- AceEth aceEth = (AceEth) matches.getAceType();
- MacAddress destinationMacAddress = aceEth.getDestinationMacAddress();
- MacAddress destinationMacAddressMask = aceEth.getDestinationMacAddressMask();
- MacAddress sourceMacAddress = aceEth.getSourceMacAddress();
- MacAddress sourceMacAddressMask = aceEth.getSourceMacAddressMask();
-
- AceEthBuilder aceEthBuilder = new AceEthBuilder(aceEth);
- aceEthBuilder.setDestinationMacAddress(sourceMacAddress);
- aceEthBuilder.setDestinationMacAddressMask(sourceMacAddressMask);
- aceEthBuilder.setSourceMacAddress(destinationMacAddress);
- aceEthBuilder.setSourceMacAddressMask(destinationMacAddressMask);
- matchesBuilder.setAceType(aceEthBuilder.build());
- }
-
- Matches invertedMatches = matchesBuilder.build();
- LOG.trace("Inverted matches: {}", invertedMatches);
- return invertedMatches;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * An executor that only executes the last submitted task. Ongoing tasks wont
- * be cancelled.
- */
-public class LastTaskExecutor implements Executor {
-
- private final Executor executor;
- private final AtomicReference<Runnable> lastTask = new AtomicReference<>();
-
- public LastTaskExecutor(Executor executor) {
- this.executor = executor;
- }
-
- @Override
- public void execute(final Runnable newTask) {
- if (newTask == null) {
- throw new NullPointerException();
- }
-
- lastTask.set(newTask);
- executor.execute(() -> {
- final Runnable runTask = lastTask.getAndSet(null);
- if (runTask != null) {
- runTask.run();
- }
- });
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionDecapNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionEncapNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionResubmitNodesNodeTableFlowWriteActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.encap.grouping.NxEncap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.encap.grouping.NxEncapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.resubmit.grouping.NxResubmitBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg2Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIpv4DstKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxReg;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxRegBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.ipv4.dst.grouping.NxmNxTunIpv4DstBuilder;
-import org.opendaylight.yangtools.yang.common.Empty;
-
-public final class OpenFlow13Utils {
- public static final long ETHERTYPE_NSH = 0x894f;
- public static final long PACKET_TYPE_NSH = 0x1894f;
- public static final long PACKET_TYPE_ETH = 0;
-
- private OpenFlow13Utils() {
- }
-
- public static void addMatchTunId(MatchBuilder match, long value) {
- NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxTunId(new NxmNxTunIdBuilder().setValue(BigInteger.valueOf(value)).build()).build();
- addExtension(match, NxmNxTunIdKey.class, am);
- }
-
- public static void addMatchTunDstIp(MatchBuilder match, Ipv4Address ipv4Address) {
- NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxTunIpv4Dst(new NxmNxTunIpv4DstBuilder().setIpv4Address(ipv4Address).build()).build();
- addExtension(match, NxmNxTunIpv4DstKey.class, am);
- }
-
- public static void addMatchEthNsh(MatchBuilder match) {
- EtherType etherType = new EtherType(ETHERTYPE_NSH);
- EthernetType ethernetType = new EthernetTypeBuilder().setType(etherType).build();
- EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetType(ethernetType).build();
- match.setEthernetMatch(ethernetMatch);
- }
-
- public static void addMatchPacketTypeNsh(MatchBuilder match) {
- PacketTypeMatch packetTypeMatch = new PacketTypeMatchBuilder().setPacketType(PACKET_TYPE_NSH).build();
- match.setPacketTypeMatch(packetTypeMatch);
- }
-
- public static void addMatchInPort(MatchBuilder match, NodeId nodeId, long inPort) {
- match.setInPort(new NodeConnectorId(nodeId.getValue() + ":" + inPort));
- }
-
- public static void addMatchNsp(MatchBuilder match, long nsp) {
- NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxNsp(new NxmNxNspBuilder().setValue(nsp).build()).build();
- addExtension(match, NxmNxNspKey.class, am);
- }
-
- public static void addMatchNsi(MatchBuilder match, short nsi) {
- NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
- .setNxmNxNsi(new NxmNxNsiBuilder().setNsi(nsi).build()).build();
- addExtension(match, NxmNxNsiKey.class, am);
- }
-
- public static void addMatchReg2(MatchBuilder match, long value) {
- NxmNxReg nxmNxReg = new NxmNxRegBuilder().setReg(NxmNxReg2.class).setValue(value).build();
- NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxReg(nxmNxReg).build();
- addExtension(match, NxmNxReg2Key.class, am);
- }
-
- private static void addExtension(MatchBuilder match, Class<? extends ExtensionKey> extensionKey,
- NxAugMatchNodesNodeTableFlow am) {
- GeneralAugMatchNodesNodeTableFlow existingAugmentations = match
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class);
- List<ExtensionList> extensions = null;
- if (existingAugmentations != null) {
- extensions = existingAugmentations.getExtensionList();
- }
- if (extensions == null) {
- extensions = new ArrayList<>();
- }
-
- extensions.add(new ExtensionListBuilder().setExtensionKey(extensionKey)
- .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
- .build());
-
- GeneralAugMatchNodesNodeTableFlow generalAugMatchNodesNode = new GeneralAugMatchNodesNodeTableFlowBuilder()
- .setExtensionList(extensions).build();
- match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, generalAugMatchNodesNode);
- }
-
- public static Action createActionResubmitTable(final short toTable, int order) {
- return createActionBuilder(order)
- .setAction(new NxActionResubmitNodesNodeTableFlowWriteActionsCaseBuilder()
- .setNxResubmit(new NxResubmitBuilder()
- .setTable(toTable)
- .build())
- .build())
- .build();
- }
-
- public static Action createActionNxLoadTunIpv4Dst(long value, int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Empty.getInstance()).build(),
- BigInteger.valueOf(value), 0,31, false));
-
- return ab.build();
- }
-
- public static Action createActionNxLoadTunId(long value, int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Empty.getInstance()).build(),
- BigInteger.valueOf(value), 0,31, false));
-
- return ab.build();
- }
-
- public static Action createActionNxEncapNsh(int order) {
- return createActionNxEncap(order, PACKET_TYPE_NSH);
- }
-
- public static Action createActionNxEncapEthernet(int order) {
- return createActionNxEncap(order, PACKET_TYPE_ETH);
- }
-
- private static Action createActionNxEncap(int order, long packetType) {
- NxEncap nxEncap = new NxEncapBuilder().setPacketType(packetType).build();
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(new NxActionEncapNodesNodeTableFlowApplyActionsCaseBuilder().setNxEncap(nxEncap).build());
- return ab.build();
- }
-
- public static Action createActionNxDecap(int order) {
- NxDecap nxDecap = new NxDecapBuilder().build();
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(new NxActionDecapNodesNodeTableFlowApplyActionsCaseBuilder().setNxDecap(nxDecap).build());
- return ab.build();
- }
-
- public static Action createActionNxMoveTunIdToNsc2Register(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(new SrcNxTunIdCaseBuilder().setNxTunId(Empty.getInstance()).build(), 0, 31,
- new DstNxNshc2CaseBuilder().setNxNshc2Dst(Empty.getInstance()).build(), 0, 31,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxMoveReg0ToNsc1Register(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(
- new SrcNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build(), 0, 31,
- new DstNxNshc1CaseBuilder().setNxNshc1Dst(Empty.getInstance()).build(), 0,31,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxMoveReg6ToNsc4Register(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(), 0, 31,
- new DstNxNshc4CaseBuilder().setNxNshc4Dst(Empty.getInstance()).build(), 0, 31,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxMoveNsc4ToReg6Register(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(new SrcNxNshc4CaseBuilder().setNxNshc4Dst(Empty.getInstance()).build(), 0, 31,
- new DstNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(), 0, 31,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxLoadNspToReg2High(long value, int order) {
- ActionBuilder ab = createActionBuilder(order);
- DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
- ab.setAction(
- // Load NSP to the 3 most significant bytes
- nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 8, 31, false));
- return ab.build();
- }
-
- public static Action createActionNxMoveReg2HighToNsp(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(
- // Move NSP from the 3 most significant bytes
- new SrcNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build(), 8, 31,
- new DstNxNspCaseBuilder().setNxNspDst(Empty.getInstance()).build(), 0, 23,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxLoadNsiToReg2Low(long value, int order) {
- ActionBuilder ab = createActionBuilder(order);
- DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
- ab.setAction(
- // Load NSI to the least significant byte
- nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 0, 7, false));
- return ab.build();
- }
-
- public static Action createActionNxMoveReg2LowToNsi(int order) {
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(nxMoveRegAction(
- // Move NSI from the least significant byte
- new SrcNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build(), 0, 7,
- new DstNxNsiCaseBuilder().setNxNsiDst(Empty.getInstance()).build(), 0, 7,
- false));
-
- return ab.build();
- }
-
- public static Action createActionNxLoadReg2(long value, int order) {
- ActionBuilder ab = createActionBuilder(order);
- DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
- ab.setAction(
- nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 0, 31, false));
- return ab.build();
- }
-
-
- private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxLoadRegAction(
- DstChoice dstChoice, BigInteger value, int startOffset, int endOffset, boolean groupBucket) {
- Dst dst = new DstBuilder().setDstChoice(dstChoice).setStart(startOffset).setEnd(endOffset).build();
- NxRegLoad regLoad = new NxRegLoadBuilder().setDst(dst).setValue(value).build();
-
- if (groupBucket) {
- return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegLoad(regLoad).build();
- } else {
- return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(regLoad).build();
- }
- }
-
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxMoveRegAction(
- SrcChoice srcChoice, int srcStartOffset, int srcEndOffset,
- DstChoice dstChoice, int dstStartOffset, int dstEndOffset,
- boolean groupBucket) {
-
- NxRegMove nxRegMove = new NxRegMoveBuilder()
- .setSrc(new SrcBuilder().setSrcChoice(srcChoice).setStart(srcStartOffset).setEnd(srcEndOffset).build())
- .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira
- .action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
- .setDstChoice(dstChoice).setStart(dstStartOffset).setEnd(dstEndOffset).build())
- .build();
-
- if (groupBucket) {
- return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegMove(nxRegMove).build();
- } else {
- return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(nxRegMove).build();
- }
- }
-
- public static Action createActionOutPort(final String portUri, final int order) {
- OutputActionBuilder output = new OutputActionBuilder();
- Uri value = new Uri(portUri);
- output.setOutputNodeConnector(value);
- ActionBuilder ab = createActionBuilder(order);
- ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
-
- return ab.build();
- }
-
- public static ActionBuilder createActionBuilder(int order) {
- ActionBuilder ab = new ActionBuilder();
- ab.setOrder(order);
- ab.withKey(new ActionKey(order));
-
- return ab;
- }
-
- public static InstructionsBuilder wrapActionsIntoApplyActionsInstruction(List<Action> theActions) {
- // Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
- aab.setAction(theActions);
-
- // Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
- ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
- ib.setOrder(0);
- ib.withKey(new InstructionKey(0));
-
- // Put our Instruction in a list of Instructions
- List<Instruction> instructions = new ArrayList<>();
- instructions.add(ib.build());
- return new InstructionsBuilder().setInstruction(instructions);
- }
-
- public static FlowBuilder createFlowBuilder(final short table, final int priority, final BigInteger cookieValue,
- final String flowName, final String flowIdStr, MatchBuilder match,
- InstructionsBuilder isb) {
- FlowBuilder flow = new FlowBuilder();
- flow.setId(new FlowId(flowIdStr));
- flow.withKey(new FlowKey(new FlowId(flowIdStr)));
- flow.setTableId(table);
- flow.setFlowName(flowName);
- flow.setCookie(new FlowCookie(cookieValue));
- flow.setCookieMask(new FlowCookie(cookieValue));
- flow.setContainerName(null);
- flow.setStrict(false);
- flow.setMatch(match.build());
- flow.setInstructions(isb.build());
- flow.setPriority(priority);
- flow.setHardTimeout(0);
- flow.setIdleTimeout(0);
- flow.setFlags(new FlowModFlags(false, false, false, false, false));
- if (null == flow.isBarrier()) {
- flow.setBarrier(Boolean.FALSE);
- }
-
- return flow;
- }
-
- public static InstructionsBuilder appendGotoTableInstruction(InstructionsBuilder isb, short nextTableId) {
- if (isb.getInstruction() == null) {
- isb.setInstruction(new ArrayList<>());
- }
- isb.getInstruction().add(createGotoTableInstruction(nextTableId, isb.getInstruction().size()));
- return isb;
- }
-
- public static Instruction createGotoTableInstruction(short nextTableId, int order) {
- GoToTableBuilder gotoIngress = createActionGotoTable(nextTableId);
-
- return new InstructionBuilder().withKey(new InstructionKey(order)).setOrder(order)
- .setInstruction(new GoToTableCaseBuilder().setGoToTable(gotoIngress.build()).build()).build();
- }
-
- public static GoToTableBuilder createActionGotoTable(final short toTable) {
- GoToTableBuilder gotoTb = new GoToTableBuilder();
- gotoTb.setTableId(toTable);
-
- return gotoTb;
- }
-
- public static NxRegLoad createNxLoadReg0(long value) {
- Dst dst = new DstBuilder()
- .setDstChoice(new DstNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build())
- .setStart(0)
- .setEnd(31)
- .build();
- return new NxRegLoadBuilder()
- .setDst(dst)
- .setValue(BigInteger.valueOf(value))
- .build();
- }
-
- public static Action createAction(
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action, int order) {
- return new ActionBuilder()
- .setOrder(order)
- .withKey(new ActionKey(order))
- .setAction(action)
- .build();
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="dataBroker"
- interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" />
-
- <reference id="rpcProviderRegistry"
- interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" />
-
- <reference id="iInterfaceManager"
- interface="org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager" />
-
-</blueprint>
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class GeniusProviderTest extends ConstantSchemaAbstractDataBrokerTest {
- private GeniusProvider geniusProvider;
-
- @Before
- public void setUp() throws Exception {
- geniusProvider = new GeniusProvider(getDataBroker(), TestOdlInterfaceRpcService.newInstance(),
- TestInterfaceManager.newInstance());
- }
-
- @Test
- @Ignore("Broken in Neon (invalid number of elements)")
- public void bindPortOnIngressClassifier() {
- // Bind the Ingress service
- geniusProvider.bindPortOnIngressClassifier(GeniusProviderTestParams.INTERFACE_NAME);
-
- // Now make sure its in the data store
- InstanceIdentifier<BoundServices> id = geniusProvider.getBindServiceId(NwConstants.SFC_CLASSIFIER_INDEX,
- GeniusProviderTestParams.INTERFACE_NAME, true);
- Optional<BoundServices> boundServices = getBoundServices(id);
- assertTrue(boundServices.isPresent());
-
- // UnBind the Ingress Service
- geniusProvider.unbindPortOnIngressClassifier(GeniusProviderTestParams.INTERFACE_NAME);
-
- // Now make sure its NOT in the data store
- assertFalse(getBoundServices(id).isPresent());
- }
-
- @Test
- @Ignore("Broken in Neon (invalid number of elements)")
- public void bindPortOnEgressClassifier() {
- // Bind the Egress service
- geniusProvider.bindPortOnEgressClassifier(
- GeniusProviderTestParams.INTERFACE_NAME,
- GeniusProviderTestParams.IPV4_ADDRESS_STR);
-
- // Now make sure its in the data store
- InstanceIdentifier<BoundServices> id = geniusProvider.getBindServiceId(
- NwConstants.EGRESS_SFC_CLASSIFIER_SERVICE_INDEX,
- GeniusProviderTestParams.INTERFACE_NAME,
- false);
- Optional<BoundServices> boundServices = getBoundServices(id);
- assertTrue(boundServices.isPresent());
-
- // UnBind the Egress Service
- geniusProvider.unbindPortOnEgressClassifier(GeniusProviderTestParams.INTERFACE_NAME);
-
- // Now make sure its NOT in the data store
- assertFalse(getBoundServices(id).isPresent());
- }
-
- @Test
- public void getNodeIdFromLogicalInterface() {
- //Optional<NodeId> getNodeIdFromLogicalInterface(String logicalInterface)
- // Test that it correctly handles the case when the ifName doesnt exist
- Optional<NodeId> nodeId = this.geniusProvider.getNodeIdFromLogicalInterface(
- GeniusProviderTestParams.INTERFACE_NAME_NO_EXIST);
- assertFalse(nodeId.isPresent());
-
- // Test that it correctly handles RPC errors
- nodeId = this.geniusProvider.getNodeIdFromLogicalInterface(
- GeniusProviderTestParams.INTERFACE_NAME_INVALID);
- assertFalse(nodeId.isPresent());
-
- // Test that it correctly returns the DpnId when everything is correct
- nodeId = this.geniusProvider.getNodeIdFromLogicalInterface(
- GeniusProviderTestParams.INTERFACE_NAME);
- assertTrue(nodeId.isPresent());
- assertEquals(nodeId.get().getValue(), GeniusProviderTestParams.NODE_ID);
- }
-
- @Test
- public void getNodeIdFromDpnId() {
- // Test that it correctly handles null input
- Optional<NodeId> nodeId = this.geniusProvider.getNodeIdFromDpnId(null);
- assertFalse(nodeId.isPresent());
-
- // Test that it correctly returns the nodeId when everything is correct
- nodeId = this.geniusProvider.getNodeIdFromDpnId(new DpnIdType(GeniusProviderTestParams.DPN_ID));
- assertTrue(nodeId.isPresent());
- assertEquals(nodeId.get().getValue(), GeniusProviderTestParams.NODE_ID);
- }
-
- @Test
- public void getIpFromDpnId() {
- // Test that it correctly handles the case when the ifName doesnt exist
- Optional<String> ipStr = this.geniusProvider.getIpFromDpnId(
- new DpnIdType(GeniusProviderTestParams.DPN_ID_NO_EXIST));
- assertFalse(ipStr.isPresent());
-
- // Test that it correctly handles RPC errors
- ipStr = this.geniusProvider.getIpFromDpnId(
- new DpnIdType(GeniusProviderTestParams.DPN_ID_INVALID));
- assertFalse(ipStr.isPresent());
-
- // Test that it correctly returns the ipStr when everything is correct
- ipStr = this.geniusProvider.getIpFromDpnId(
- new DpnIdType(GeniusProviderTestParams.DPN_ID));
- assertTrue(ipStr.isPresent());
- assertEquals(ipStr.get(), GeniusProviderTestParams.IPV4_ADDRESS_STR);
- }
-
- @Test
- public void getDpnIdFromInterfaceName() {
- // Test that it correctly handles the case when the ifName doesnt exist
- Optional<DpnIdType> dpnId = this.geniusProvider.getDpnIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME_NO_EXIST);
- assertFalse(dpnId.isPresent());
-
- // Test that it correctly handles RPC errors
- dpnId = this.geniusProvider.getDpnIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME_INVALID);
- assertFalse(dpnId.isPresent());
-
- // Test that it correctly returns the DpnId when everything is correct
- dpnId = this.geniusProvider.getDpnIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME);
- assertTrue(dpnId.isPresent());
- assertEquals(dpnId.get().getValue().toJava(), GeniusProviderTestParams.DPN_ID);
- }
-
- @Test
- public void getNodeConnectorIdFromInterfaceName() {
- // Test that it correctly handles the case when the ifName doesnt exist
- Optional<String> nodeConnStr = this.geniusProvider.getNodeConnectorIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME_NO_EXIST);
- assertFalse(nodeConnStr.isPresent());
-
- // Test that it correctly handles RPC errors
- nodeConnStr = this.geniusProvider.getNodeConnectorIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME_INVALID);
- assertFalse(nodeConnStr.isPresent());
-
- // Test that it correctly returns the NodeConnectorId when everything is correct
- nodeConnStr = this.geniusProvider.getNodeConnectorIdFromInterfaceName(
- GeniusProviderTestParams.INTERFACE_NAME);
- assertTrue(nodeConnStr.isPresent());
- assertEquals(nodeConnStr.get(), GeniusProviderTestParams.NODE_CONNECTOR_ID_PREFIX
- + GeniusProviderTestParams.INTERFACE_NAME);
- }
-
- @Test
- public void getEgressVxlanPortForNode() {
- // Test that it correctly handles the case when the dpnId doesnt exist
- Optional<Long> ofPort = this.geniusProvider.getEgressVxlanPortForNode(
- GeniusProviderTestParams.DPN_ID_NO_EXIST);
- assertFalse(ofPort.isPresent());
-
- // Test that it correctly handles when there are no tunnel ports on the bridge
- ofPort = this.geniusProvider.getEgressVxlanPortForNode(GeniusProviderTestParams.DPN_ID_NO_PORTS);
- assertFalse(ofPort.isPresent());
-
- // Test that it correctly handles when there are no VXGPE tunnel ports on the bridge
- ofPort = this.geniusProvider.getEgressVxlanPortForNode(GeniusProviderTestParams.DPN_ID_NO_VXGPE_PORTS);
- assertFalse(ofPort.isPresent());
-
- // Test that is correctly handles when a terminationPoint has no options
- ofPort = this.geniusProvider.getEgressVxlanPortForNode(GeniusProviderTestParams.DPN_ID_NO_OPTIONS);
- assertFalse(ofPort.isPresent());
-
- // Test that it correctly returns the OpenFlow port when everything is correct
- ofPort = this.geniusProvider.getEgressVxlanPortForNode(GeniusProviderTestParams.DPN_ID);
- assertTrue(ofPort.isPresent());
- assertEquals(ofPort.get().longValue(), GeniusProviderTestParams.OF_PORT);
- }
-
- Optional<BoundServices> getBoundServices(InstanceIdentifier<BoundServices> id) {
- return Optional.ofNullable(MDSALUtil.read(getDataBroker(), LogicalDatastoreType.CONFIGURATION, id).orNull());
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import java.math.BigInteger;
-
-public interface GeniusProviderTestParams {
- String INTERFACE_NAME = "123456";
- String INTERFACE_NAME_INVALID = "000000";
- String INTERFACE_NAME_NO_EXIST = "111111";
-
- BigInteger DPN_ID = new BigInteger("1234567890");
- BigInteger DPN_ID_NO_PORTS = new BigInteger("111111111");
- BigInteger DPN_ID_NO_VXGPE_PORTS = new BigInteger("222222222");
- BigInteger DPN_ID_NO_OPTIONS = new BigInteger("333333333");
- BigInteger DPN_ID_INVALID = new BigInteger("666666666");
- BigInteger DPN_ID_NO_EXIST = new BigInteger("999999999");
-
- String NODE_ID = "openflow:" + DPN_ID.toString();
- String NODE_CONNECTOR_ID_PREFIX = "openflow:" + DPN_ID.toString() + ":";
- String IPV4_ADDRESS_STR = "192.168.0.1";
- long OF_PORT = 42L;
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkMaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetworkBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class NetvirtProviderTest extends ConstantSchemaAbstractDataBrokerTest {
- private static final String NW_UUID_STR = "177bef73-514e-4922-990f-d7aba0f3b0f4";
- private static final String NW_UUID_NOEXIST_STR = "177bef73-5555-2222-0000-d7aba0f3b0f4";
- private static final String SUBNET_UUID_STR = "33333333-514e-4922-990f-d7aba0f3b0f4";
- private static final String PORT_UUID_STR = "44444444-5555-2222-0000-d7aba0f3b0f4";
- private static final String EMPTY_STR = "";
-
- private NetvirtProvider netvirtProvider;
-
- @Before
- public void setUp() throws Exception {
- this.netvirtProvider = new NetvirtProvider(getDataBroker());
- }
-
- @Test
- public void getLogicalInterfacesFromNeutronNetwork() {
-
- // Network doesnt exist
- NeutronNetworkBuilder nwBuilder = new NeutronNetworkBuilder();
- nwBuilder.setNetworkUuid(NW_UUID_NOEXIST_STR);
- List<String> interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
- assertTrue(interfaces.isEmpty());
-
- // Network exists, subnet list empty
- createNetworkMap(NW_UUID_STR);
- nwBuilder = new NeutronNetworkBuilder();
- nwBuilder.setNetworkUuid(NW_UUID_STR);
- interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
- assertTrue(interfaces.isEmpty());
-
- // Network exists, subnet does not exist
- createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, false, EMPTY_STR);
- nwBuilder = new NeutronNetworkBuilder();
- nwBuilder.setNetworkUuid(NW_UUID_STR);
- interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
- assertTrue(interfaces.isEmpty());
-
- // Network exists, subnet exists, no ports
- createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, EMPTY_STR);
- nwBuilder = new NeutronNetworkBuilder();
- nwBuilder.setNetworkUuid(NW_UUID_STR);
- interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
- assertTrue(interfaces.isEmpty());
-
- // Network exists, subnet exists, port exists
- createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, PORT_UUID_STR);
- nwBuilder = new NeutronNetworkBuilder();
- nwBuilder.setNetworkUuid(NW_UUID_STR);
- interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
- assertFalse(interfaces.isEmpty());
- }
-
- private NetworkMapBuilder createNetworkMap(String nwUuidStr) {
- Uuid nwUuid = new Uuid(nwUuidStr);
- NetworkMapBuilder nwMapBuilder = new NetworkMapBuilder();
- nwMapBuilder.setNetworkId(nwUuid);
- storeNetworkMap(nwUuid, nwMapBuilder.build());
-
- return nwMapBuilder;
- }
-
- private void createNetworkMap(String nwUuidStr, String subnetUuidStr, boolean storeSubnet, String portUuidStr) {
- SubnetmapBuilder subnetBuilder = new SubnetmapBuilder();
- if (!portUuidStr.isEmpty()) {
- List<Uuid> portIdList = new ArrayList<>();
- portIdList.add(new Uuid(portUuidStr));
- subnetBuilder.setPortList(portIdList);
- }
-
- Uuid subnetUuid = new Uuid(subnetUuidStr);
- subnetBuilder.setId(subnetUuid);
- List<Uuid> subnetIdList = new ArrayList<>();
- subnetIdList.add(subnetUuid);
-
- NetworkMapBuilder nwMapBuilder = createNetworkMap(nwUuidStr);
- nwMapBuilder.setSubnetIdList(subnetIdList);
- storeNetworkMap(new Uuid(nwUuidStr), nwMapBuilder.build());
-
- // Simulates NetworkMap has subnet list, but subnets dont exist
- if (storeSubnet) {
- storeSubnetMap(subnetUuid, subnetBuilder.build());
- }
- }
-
- @SuppressWarnings("deprecation")
- private void storeNetworkMap(Uuid nwUuid, NetworkMap nwMap) {
- InstanceIdentifier<NetworkMap> networkMapIdentifier =
- InstanceIdentifier.builder(NetworkMaps.class)
- .child(NetworkMap.class,new NetworkMapKey(nwUuid)).build();
-
- MDSALUtil.syncWrite(getDataBroker(), LogicalDatastoreType.CONFIGURATION, networkMapIdentifier, nwMap);
- }
-
- @SuppressWarnings("deprecation")
- private void storeSubnetMap(Uuid subnetUuid, Subnetmap subnetMap) {
- InstanceIdentifier<Subnetmap> subnetId =
- InstanceIdentifier.builder(Subnetmaps.class)
- .child(Subnetmap.class, new SubnetmapKey(subnetUuid)).build();
-
- MDSALUtil.syncWrite(getDataBroker(), LogicalDatastoreType.CONFIGURATION, subnetId, subnetMap);
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.net.InetAddresses;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.netvirt.sfc.classifier.utils.AclMatches;
-import org.opendaylight.netvirt.sfc.classifier.utils.OpenFlow13Utils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionDecapNodesNodeTableFlowApplyActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionEncapNodesNodeTableFlowApplyActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionResubmitNodesNodeTableFlowWriteActionsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc1Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc2Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4Case;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNsiCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNspCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
-import org.opendaylight.yangtools.yang.common.Empty;
-
-
-public class OpenFlow13ProviderTest {
-
- private OpenFlow13Provider openflowProvider;
- private final NodeId nodeId;
- private static final String NODE_ID_STR = "openflow:1234";
- private static final String SFF_IP_STR = "192.168.0.1";
- private static final Long IN_PORT = 8L;
- private static final Long OUT_PORT = 12L;
- private static final Long NSP = 6500L;
- private static final Short NSI = (short) 255;
- private static final Short EGRESS_NSI = (short) 253;
-
- public OpenFlow13ProviderTest() {
- nodeId = new NodeId(NODE_ID_STR);
- }
-
- @Before
- public void setUp() {
- openflowProvider = new OpenFlow13Provider();
- }
-
- @Test
- public void createIngressClassifierFilterTunnelNshFlow() {
- Flow flow = openflowProvider.createIngressClassifierFilterTunnelNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_TUN_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_TUN_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.SFC_TRANSPORT_INGRESS_TABLE);
- }
-
- @Test
- public void createIngressClassifierFilterEthNshFlow() {
- Flow flow = openflowProvider.createIngressClassifierFilterEthNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_ETH_NSH_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchEthNsh(flow.getMatch());
- checkMatchTunDstIp(flow.getMatch(), OpenFlow13Provider.NULL_IP);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.LPORT_DISPATCHER_TABLE);
- }
-
- @Test
- public void createIngressClassifierFilterNshFlow() {
- Flow flow = openflowProvider.createIngressClassifierFilterNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchTunDstIp(flow.getMatch(), OpenFlow13Provider.NULL_IP);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.LPORT_DISPATCHER_TABLE);
- }
-
- @Test
- public void createIngressClassifierFilterChainEgressFlow() {
- Flow flow = openflowProvider.createIngressClassifierFilterChainEgressFlow(nodeId, NSP, EGRESS_NSI);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_CHAIN_EGRESS_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME
- + nodeId.getValue() + "_" + NSP);
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchNsp(flow.getMatch(), NSP);
- checkMatchNsi(flow.getMatch(), EGRESS_NSI);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- Instruction curInstruction = flow.getInstructions().getInstruction().get(0).getInstruction();
- List<Action> actionList = checkApplyActionSize(curInstruction, 3);
- checkActionMoveNsc4(actionList.get(0), true);
- checkActionMoveReg(actionList.get(0), NxmNxReg6.class, 0, 31, false);
- checkActionDecap(actionList.get(1));
- checkActionResubmit(curInstruction, NwConstants.EGRESS_LPORT_DISPATCHER_TABLE);
- }
-
- @Test
- public void createIngressClassifierFilterNoNshFlow() {
- Flow flow = openflowProvider.createIngressClassifierFilterNoNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchEmpty(flow.getMatch());
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionGotoTable(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE);
- }
-
- @Test
- public void createIngressClassifierAclFlow() {
- // Create an empty AclMatch to pass in
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(new AceIpBuilder().build());
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
-
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- Flow flow = openflowProvider.createIngressClassifierAclFlow(
- nodeId, matchBuilder, IN_PORT, NSP, NSI);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_MATCH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue()
- + matchBuilder.build().toString());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_COOKIE);
-
- // Only checking the inport match, since the rest is tested in AclMatchesTest
- checkMatchInport(flow.getMatch(), nodeId.getValue() + ":" + IN_PORT);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- Instruction curInstruction = flow.getInstructions().getInstruction().get(0).getInstruction();
- List<Action> actionList = checkApplyActionSize(curInstruction, 3);
-
- checkActionLoadReg(actionList.get(0), NxmNxReg2.class, 8, 31, NSP);
- checkActionLoadReg(actionList.get(1), NxmNxReg2.class, 0, 7, NSI);
- checkActionResubmit(curInstruction, NwConstants.LPORT_DISPATCHER_TABLE);
- }
- }
-
- @Test
- public void createIngressClassifierAclNoMatchFlow() {
- Flow flow = openflowProvider.createIngressClassifierAclNoMatchFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_NOMATCH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.INGRESS_CLASSIFIER_ACL_COOKIE);
-
- checkMatchEmpty(flow.getMatch());
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.LPORT_DISPATCHER_TABLE);
- }
-
- @Test
- public void createEgressClassifierFilterNshFlow() {
- Flow flow = openflowProvider.createEgressClassifierFilterNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_NSH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_NSH_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchEmpty(flow.getMatch());
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionGotoTable(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE);
- }
-
- @Test
- public void createEgressClassifierFilterNoNshFlow() {
- Flow flow = openflowProvider.createEgressClassifierFilterNoNshFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_NONSH_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_NONSH_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_FILTER_COOKIE);
-
- checkMatchReg(flow.getMatch(), NxmNxReg2.class, 0);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.EGRESS_LPORT_DISPATCHER_TABLE);
- }
-
- @Test
- public void createEgressClassifierNextHopFlow() {
- Flow flow = openflowProvider.createEgressClassifierNextHopFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_NEXTHOP_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_NEXTHOP_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_NEXTHOP_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_NEXTHOP_COOKIE);
-
- checkMatchEmpty(flow.getMatch());
-
- assertEquals(2, flow.getInstructions().getInstruction().size());
- Instruction curInstruction = flow.getInstructions().getInstruction().get(0).getInstruction();
- List<Action> actionList = checkApplyActionSize(curInstruction, 8);
-
- checkActionEncap(actionList.get(0), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkActionMoveReg(actionList.get(1), NxmNxReg2.class, 8,31, true);
- checkActionMoveNsp(actionList.get(1), false);
- checkActionMoveReg(actionList.get(2), NxmNxReg2.class, 0,7, true);
- checkActionMoveNsi(actionList.get(2), false);
- checkActionLoadReg(actionList.get(3), NxmNxReg2.class, 0 , 31, 0);
- checkActionMoveReg(actionList.get(4), NxmNxReg0.class, 0, 31, true);
- checkActionMoveNsc1(actionList.get(4), false);
- checkActionMoveTunId(actionList.get(5), true);
- checkActionMoveNsc2(actionList.get(5), false);
- checkActionMoveReg(actionList.get(6), NxmNxReg6.class, 0, 31, true);
- checkActionMoveNsc4(actionList.get(6), false);
- checkActionLoadTunId(actionList.get(7), OpenFlow13Provider.SFC_TUNNEL_ID);
-
- curInstruction = flow.getInstructions().getInstruction().get(1).getInstruction();
- checkActionGotoTable(curInstruction, NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
- }
-
- @Test
- public void createEgressClassifierTransportEgressLocalFlow() {
- Flow flow = openflowProvider.createEgressClassifierTransportEgressLocalFlow(nodeId, NSP);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_EGRESS_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + NSP);
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchNsp(flow.getMatch(), NSP);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionResubmit(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.SFC_TRANSPORT_INGRESS_TABLE);
- }
-
- @Test
- public void createEgressClassifierTransportEgressRemoteNshFlow() {
- Flow flow = openflowProvider.createEgressClassifierTransportEgressRemoteNshFlow(
- nodeId, NSP, OUT_PORT, SFF_IP_STR);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_EGRESS_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + NSP);
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchNsp(flow.getMatch(), NSP);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- List<Action> actionList = checkApplyActionSize(
- flow.getInstructions().getInstruction().get(0).getInstruction(), 2);
-
- checkActionLoadTunIpv4(actionList.get(0), SFF_IP_STR);
- checkActionOutport(actionList.get(1), "output:" + OUT_PORT);
- }
-
- @Test
- public void createEgressClassifierTransportEgressRemoteEthNshFlow() {
- Flow flow = openflowProvider.createEgressClassifierTransportEgressRemoteEthNshFlow(
- nodeId, NSP, OUT_PORT, SFF_IP_STR);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.EGRESS_SFC_CLASSIFIER_EGRESS_TABLE);
- assertEquals(flow.getPriority().intValue(), OpenFlow13Provider.EGRESS_CLASSIFIER_EGRESS_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_FLOW_NAME + nodeId.getValue() + "_" + NSP);
- assertEquals(flow.getCookie().getValue().toJava(), OpenFlow13Provider.EGRESS_CLASSIFIER_TPORTEGRESS_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchNsp(flow.getMatch(), NSP);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- List<Action> actionList = checkApplyActionSize(
- flow.getInstructions().getInstruction().get(0).getInstruction(), 3);
-
- checkActionEncap(actionList.get(0), OpenFlow13Utils.PACKET_TYPE_ETH);
- checkActionLoadTunIpv4(actionList.get(1), SFF_IP_STR);
- checkActionOutport(actionList.get(2), "output:" + OUT_PORT);
- }
-
- @Test
- public void createIngressClassifierTunnelEthNshTrafficCaptureFlow() {
- Flow flow = openflowProvider.createIngressClassifierTunnelEthNshTrafficCaptureFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INTERNAL_TUNNEL_TABLE);
- assertEquals(flow.getPriority().intValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_ETH_NSH_TRAFFIC_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_COOKIE);
-
- checkMatchEthNsh(flow.getMatch());
- checkMatchTunId(flow.getMatch(), OpenFlow13Provider.SFC_TUNNEL_ID);
-
- assertEquals(2, flow.getInstructions().getInstruction().size());
- List<Action> actionList = checkApplyActionSize(
- flow.getInstructions().getInstruction().get(0).getInstruction(), 1);
- checkActionDecap(actionList.get(0));
- checkActionGotoTable(flow.getInstructions().getInstruction().get(1).getInstruction(),
- NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- }
-
- @Test
- public void createIngressClassifierTunnelNshTrafficCaptureFlow() {
- Flow flow = openflowProvider.createIngressClassifierTunnelNshTrafficCaptureFlow(nodeId);
-
- assertEquals(flow.getTableId().shortValue(), NwConstants.INTERNAL_TUNNEL_TABLE);
- assertEquals(flow.getPriority().intValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_PRIORITY);
- assertEquals(flow.getId().getValue(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_NSH_TRAFFIC_FLOW_NAME + nodeId.getValue());
- assertEquals(flow.getCookie().getValue().toJava(),
- OpenFlow13Provider.INGRESS_CLASSIFIER_CAPTURE_SFC_TUNNEL_TRAFFIC_COOKIE);
-
- checkMatchPacketType(flow.getMatch(), OpenFlow13Utils.PACKET_TYPE_NSH);
- checkMatchTunId(flow.getMatch(), OpenFlow13Provider.SFC_TUNNEL_ID);
-
- assertEquals(1, flow.getInstructions().getInstruction().size());
- checkActionGotoTable(flow.getInstructions().getInstruction().get(0).getInstruction(),
- NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE);
- }
-
- //
- // Internal util methods to check Flow Matches
- //
-
- private void checkMatchEmpty(Match match) {
- assertNull(match.getPacketTypeMatch());
- assertNull(match.getEthernetMatch());
- assertNull(match.getIpMatch());
- assertNull(match.getLayer3Match());
- assertNull(match.getLayer4Match());
- assertNull(match.augmentation(GeneralAugMatchNodesNodeTableFlow.class));
- }
-
- private void checkMatchPacketType(Match match, long packetType) {
- assertEquals(packetType, match.getPacketTypeMatch().getPacketType().longValue());
- }
-
- private void checkMatchTunId(Match match, long value) {
- GeneralAugMatchNodesNodeTableFlow genAug =
- match.augmentation(GeneralAugMatchNodesNodeTableFlow.class);
-
- assertNotNull(genAug);
-
- List<ExtensionList> extensions = genAug.getExtensionList();
- for (ExtensionList extensionList : extensions) {
- Extension extension = extensionList.getExtension();
- NxAugMatchNodesNodeTableFlow nxAugMatch = extension.augmentation(NxAugMatchNodesNodeTableFlow.class);
-
- if (nxAugMatch.getNxmNxTunId() != null) {
- assertEquals(nxAugMatch.getNxmNxTunId().getValue().longValue(), value);
- }
- }
- }
-
- private void checkMatchTunDstIp(Match match, Ipv4Address value) {
- GeneralAugMatchNodesNodeTableFlow genAug =
- match.augmentation(GeneralAugMatchNodesNodeTableFlow.class);
-
- assertNotNull(genAug);
-
- List<ExtensionList> extensions = genAug.getExtensionList();
- for (ExtensionList extensionList : extensions) {
- Extension extension = extensionList.getExtension();
- NxAugMatchNodesNodeTableFlow nxAugMatch = extension.augmentation(NxAugMatchNodesNodeTableFlow.class);
-
- if (nxAugMatch.getNxmNxTunIpv4Dst() != null) {
- assertEquals(nxAugMatch.getNxmNxTunIpv4Dst().getIpv4Address(), value);
- }
- }
- }
-
- private void checkMatchEthNsh(Match match) {
- assertEquals(match.getEthernetMatch().getEthernetType().getType().getValue().longValue(),
- OpenFlow13Utils.ETHERTYPE_NSH);
- }
-
- private void checkMatchInport(Match match, String inportStr) {
- assertEquals(inportStr, match.getInPort().getValue());
- }
-
- private void checkMatchNsp(Match match, long nsp) {
- GeneralAugMatchNodesNodeTableFlow genAug =
- match.augmentation(GeneralAugMatchNodesNodeTableFlow.class);
-
- assertNotNull(genAug);
-
- List<ExtensionList> extensions = genAug.getExtensionList();
- for (ExtensionList extensionList : extensions) {
- Extension extension = extensionList.getExtension();
- NxAugMatchNodesNodeTableFlow nxAugMatch = extension.augmentation(NxAugMatchNodesNodeTableFlow.class);
-
- if (nxAugMatch.getNxmNxNsp() != null) {
- assertEquals(nxAugMatch.getNxmNxNsp().getValue().longValue(), nsp);
- }
- }
- }
-
- private void checkMatchNsi(Match match, short nsi) {
- GeneralAugMatchNodesNodeTableFlow genAug =
- match.augmentation(GeneralAugMatchNodesNodeTableFlow.class);
-
- assertNotNull(genAug);
-
- List<ExtensionList> extensions = genAug.getExtensionList();
- for (ExtensionList extensionList : extensions) {
- Extension extension = extensionList.getExtension();
- NxAugMatchNodesNodeTableFlow nxAugMatch = extension.augmentation(NxAugMatchNodesNodeTableFlow.class);
-
- if (nxAugMatch.getNxmNxNsi() != null) {
- assertEquals(nxAugMatch.getNxmNxNsi().getNsi().shortValue(), nsi);
- }
- }
- }
-
- private void checkMatchReg(Match match, Class<? extends NxmNxReg> reg, long value) {
- GeneralAugMatchNodesNodeTableFlow genAug =
- match.augmentation(GeneralAugMatchNodesNodeTableFlow.class);
-
- assertNotNull(genAug);
-
- List<ExtensionList> extensions = genAug.getExtensionList();
- for (ExtensionList extensionList : extensions) {
- Extension extension = extensionList.getExtension();
- NxAugMatchNodesNodeTableFlow nxAugMatch = extension.augmentation(NxAugMatchNodesNodeTableFlow.class);
-
- if (nxAugMatch.getNxmNxReg() != null) {
- assertEquals(nxAugMatch.getNxmNxReg().getReg(), reg);
- assertEquals(nxAugMatch.getNxmNxReg().getValue().longValue(), value);
- assertNull(nxAugMatch.getNxmNxReg().getMask());
- }
- }
- }
-
- //
- // Internal util methods to check Flow Actions
- //
-
- private void checkActionResubmit(Instruction curInstruction, short nextTableId) {
- assertTrue(curInstruction instanceof ApplyActionsCase);
- boolean resubmitActionFound = false;
- for (Action action : ((ApplyActionsCase) curInstruction).getApplyActions().getAction()) {
- if (action.getAction() instanceof NxActionResubmitNodesNodeTableFlowWriteActionsCase) {
- NxActionResubmitNodesNodeTableFlowWriteActionsCase resubmitAction =
- (NxActionResubmitNodesNodeTableFlowWriteActionsCase) action.getAction();
- assertEquals(resubmitAction.getNxResubmit().getTable().shortValue(), nextTableId);
- resubmitActionFound = true;
- }
- }
-
- assertTrue(resubmitActionFound);
- }
-
- private void checkActionGotoTable(Instruction curInstruction, short nextTableId) {
- if (curInstruction instanceof GoToTableCase) {
- GoToTableCase goToTablecase = (GoToTableCase) curInstruction;
- assertEquals(goToTablecase.getGoToTable().getTableId().shortValue(), nextTableId);
- } else {
- fail();
- }
- }
-
- private List<Action> checkApplyActionSize(Instruction curInstruction, int numActions) {
- assertTrue(curInstruction instanceof ApplyActionsCase);
- ApplyActionsCase action = (ApplyActionsCase) curInstruction;
- assertEquals(numActions, action.getApplyActions().getAction().size());
-
- return action.getApplyActions().getAction();
- }
-
- private void checkActionLoadTunIpv4(Action action, String ip) {
- long ipl = InetAddresses.coerceToInteger(InetAddresses.forString(ip)) & 0xffffffffL;
- NxActionRegLoadNodesNodeTableFlowApplyActionsCase regLoad =
- (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
- DstNxTunIpv4DstCase tunDstTypeCase = (DstNxTunIpv4DstCase) regLoad.getNxRegLoad().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), tunDstTypeCase.getNxTunIpv4Dst());
- assertEquals(regLoad.getNxRegLoad().getValue().longValue(), ipl);
- }
-
- private void checkActionLoadTunId(Action action, long tunId) {
- NxActionRegLoadNodesNodeTableFlowApplyActionsCase regLoad =
- (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
- DstNxTunIdCase mdTypeCase = (DstNxTunIdCase) regLoad.getNxRegLoad().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), mdTypeCase.getNxTunId());
- assertEquals(regLoad.getNxRegLoad().getValue().longValue(), tunId);
- }
-
- private void checkActionOutport(Action action, String outport) {
- OutputActionCase output = (OutputActionCase) action.getAction();
- assertEquals(output.getOutputAction().getOutputNodeConnector().getValue(), outport);
- }
-
- private void checkActionMoveNsp(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- assertEquals(Empty.getInstance(), ((SrcNxNspCase) regMove.getNxRegMove()
- .getSrc().getSrcChoice()).getNxNspDst());
- } else {
- assertEquals(Empty.getInstance(), ((DstNxNspCase) regMove.getNxRegMove()
- .getDst().getDstChoice()).getNxNspDst());
- }
- }
-
- private void checkActionMoveNsi(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- assertEquals(Empty.getInstance(), ((SrcNxNsiCase) regMove.getNxRegMove()
- .getSrc().getSrcChoice()).getNxNsiDst());
- } else {
- assertEquals(Empty.getInstance(), ((DstNxNsiCase) regMove.getNxRegMove()
- .getDst().getDstChoice()).getNxNsiDst());
- }
- }
-
- private void checkActionMoveNsc1(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- SrcNxNshc1Case src = (SrcNxNshc1Case) regMove.getNxRegMove().getSrc().getSrcChoice();
- assertEquals(Empty.getInstance(), src.getNxNshc1Dst());
- } else {
- DstNxNshc1Case dst = (DstNxNshc1Case) regMove.getNxRegMove().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), dst.getNxNshc1Dst());
- }
- }
-
- private void checkActionMoveNsc2(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- SrcNxNshc2Case src = (SrcNxNshc2Case) regMove.getNxRegMove().getSrc().getSrcChoice();
- assertEquals(Empty.getInstance(), src.getNxNshc2Dst());
- } else {
- DstNxNshc2Case dst = (DstNxNshc2Case) regMove.getNxRegMove().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), dst.getNxNshc2Dst());
- }
- }
-
- private void checkActionMoveNsc4(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- SrcNxNshc4Case src = (SrcNxNshc4Case) regMove.getNxRegMove().getSrc().getSrcChoice();
- assertEquals(Empty.getInstance(), src.getNxNshc4Dst());
- } else {
- DstNxNshc4Case dst = (DstNxNshc4Case) regMove.getNxRegMove().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), dst.getNxNshc4Dst());
- }
- }
-
- private void checkActionMoveTunId(Action action, boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- SrcNxTunIdCase src = (SrcNxTunIdCase) regMove.getNxRegMove().getSrc().getSrcChoice();
- assertEquals(Empty.getInstance(), src.getNxTunId());
- } else {
- DstNxTunIdCase dst = (DstNxTunIdCase) regMove.getNxRegMove().getDst().getDstChoice();
- assertEquals(Empty.getInstance(), dst.getNxTunId());
- }
- }
-
- private void checkActionLoadReg(Action action, Class<? extends NxmNxReg> reg,
- int startOffset,
- int endOffset,
- long value) {
- NxActionRegLoadNodesNodeTableFlowApplyActionsCase regLoad =
- (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
- assertEquals(reg, ((DstNxRegCase) regLoad.getNxRegLoad().getDst().getDstChoice()).getNxReg());
- assertEquals(startOffset, regLoad.getNxRegLoad().getDst().getStart().intValue());
- assertEquals(endOffset, regLoad.getNxRegLoad().getDst().getEnd().intValue());
- assertEquals(value, regLoad.getNxRegLoad().getValue().longValue());
- }
-
- private void checkActionMoveReg(Action action, Class<? extends NxmNxReg> reg,
- int startOffset,
- int endOffset,
- boolean checkSrc) {
- NxActionRegMoveNodesNodeTableFlowApplyActionsCase regMove =
- (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
- if (checkSrc) {
- assertEquals(reg, ((SrcNxRegCase) regMove.getNxRegMove().getSrc().getSrcChoice()).getNxReg());
- assertEquals(startOffset, regMove.getNxRegMove().getSrc().getStart().intValue());
- assertEquals(endOffset, regMove.getNxRegMove().getSrc().getEnd().intValue());
- } else {
- assertEquals(reg, ((DstNxRegCase) regMove.getNxRegMove().getDst().getDstChoice()).getNxReg());
- assertEquals(startOffset, regMove.getNxRegMove().getDst().getStart().intValue());
- assertEquals(endOffset, regMove.getNxRegMove().getDst().getEnd().intValue());
- }
- }
-
- private void checkActionEncap(Action action, long packetType) {
- NxActionEncapNodesNodeTableFlowApplyActionsCase encap =
- (NxActionEncapNodesNodeTableFlowApplyActionsCase) action.getAction();
- assertEquals(packetType, encap.getNxEncap().getPacketType().longValue());
- }
-
- private void checkActionDecap(Action action) {
- NxActionDecapNodesNodeTableFlowApplyActionsCase decap =
- (NxActionDecapNodesNodeTableFlowApplyActionsCase) action.getAction();
- assertNotNull(decap.getNxDecap());
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHopBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterfaceBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class SfcProviderTest extends ConstantSchemaAbstractDataBrokerTest {
- private static final String RSP_NAME = "RSP1";
- private static final String RSP_NAME_NOEXIST = "RSP_NOEXIST";
- private static final String SFC_NAME = "SFC1";
- private static final String SF_NAME = "SF1";
- private static final String SFF_NAME = "SFF1";
- private static final String SFF_DPL_NAME = "SFF_DPL";
- private static final String LOGICAL_IF_NAME = "eccb57ae-5a2e-467f-823e-45d7bb2a6a9a";
- private static final Long PATH_ID = Long.valueOf(1);
-
- private SfcProvider sfcProvider;
-
- @Before
- public void setUp() throws Exception {
- sfcProvider = new SfcProvider(getDataBroker());
- }
-
- @Test
- public void getRenderedServicePath() {
- RspName rspName = new RspName(RSP_NAME);
- RenderedServicePathBuilder rspBuilder = createRsp(rspName);
- storeRsp(rspName, rspBuilder.build());
-
- Optional<RenderedServicePath> rspOptional = this.sfcProvider.getRenderedServicePath(RSP_NAME);
- assertTrue(rspOptional.isPresent());
- }
-
- @Test
- public void getRenderedServicePathNonExistantRsp() {
- Optional<RenderedServicePath> rspOptional = this.sfcProvider.getRenderedServicePath(RSP_NAME_NOEXIST);
- assertFalse(rspOptional.isPresent());
- }
-
- @Test
- public void getRenderedServicePathFromSfc() {
- // This method isnt implemented yet, so it should return empty
- Optional<RenderedServicePath> rspOptional = this.sfcProvider.getRenderedServicePathFromSfc(SFC_NAME);
- assertFalse(rspOptional.isPresent());
- }
-
- @Test
- public void getFirstHopSfInterfaceFromRsp() {
- RspName rspName = new RspName(RSP_NAME);
-
- // Check RSP with no hops
- RenderedServicePathBuilder rspBuilder = createRsp(rspName);
- Optional<String> ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with no SF name
- rspBuilder = createRsp(rspName, true, false, false, false, false, false, false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with SF name, but no SFF name
- rspBuilder = createRsp(rspName, true, true, false, false, false, false,false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with SF name, but SFF doesnt exist
- rspBuilder = createRsp(rspName, true, true, true, false, false, false,false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with SF and SFF, but SFF has no dictionary
- rspBuilder = createRsp(rspName, true, true, true, false, false, true, false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with SF and SFF, but SFF has no dictionary entry for SF
- rspBuilder = createRsp(rspName, true, true, true, true, false, true, false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with SF, SFF name, SFF exists, but has no DPL
- rspBuilder = createRsp(rspName, true, true, true, true, true, true, false, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP with Sfm SFF name, SFF exists, has DPL, but not of type LogicalInterfaceLocator
- rspBuilder = createRsp(rspName, true, true, true, true, true, true, true, false);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertFalse(ifName.isPresent());
-
- // Check RSP when its all created correctly
- rspBuilder = createRsp(rspName, true, true, true, true, true, true, true, true);
- ifName = this.sfcProvider.getFirstHopIngressInterfaceFromRsp(rspBuilder.build());
- assertTrue(ifName.isPresent());
- assertEquals(ifName.get(), LOGICAL_IF_NAME);
- }
-
- private RenderedServicePathBuilder createRsp(RspName rspName) {
- return new RenderedServicePathBuilder()
- .setName(rspName)
- .setServiceChainName(SfcName.getDefaultInstance(SFC_NAME))
- .setPathId(PATH_ID)
- .setReversePath(false);
- }
-
- private RenderedServicePathBuilder createRsp(RspName rspName, boolean hasHops, boolean hasSfName,
- boolean hasSffName, boolean hasDict, boolean hasSfDict,
- boolean createSff, boolean createSffDpl,
- boolean createLogicalSfDpl) {
- RenderedServicePathBuilder rspBuilder = createRsp(rspName);
- SffName sffName = new SffName(SFF_NAME);
- SfName sfName = new SfName(SF_NAME);
-
- RenderedServicePathHopBuilder rspHopBuilder = new RenderedServicePathHopBuilder();
- if (hasSfName) {
- rspHopBuilder.setServiceFunctionName(sfName);
- }
-
- if (hasSffName) {
- rspHopBuilder.setServiceFunctionForwarder(sffName);
- }
-
- if (hasHops) {
- List<RenderedServicePathHop> hops = new ArrayList<>();
- hops.add(rspHopBuilder.build());
- rspBuilder.setRenderedServicePathHop(hops);
- }
-
- ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
- ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder = new ServiceFunctionDictionaryBuilder();
- serviceFunctionDictionaryBuilder.setName(sfName);
-
- if (hasSfDict) {
- SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
- sffSfDataPlaneLocatorBuilder.setSffDplName(new SffDataPlaneLocatorName(SFF_DPL_NAME));
- serviceFunctionDictionaryBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
- }
-
- if (hasDict) {
- sffBuilder.setServiceFunctionDictionary(
- Collections.singletonList(serviceFunctionDictionaryBuilder.build()));
- }
-
- SffDataPlaneLocatorBuilder sffDplBuilder = new SffDataPlaneLocatorBuilder();
- DataPlaneLocatorBuilder dataPlaneLocatorBuilder = new DataPlaneLocatorBuilder();
- if (createLogicalSfDpl) {
- LogicalInterfaceBuilder liBuilder = new LogicalInterfaceBuilder();
- liBuilder.setInterfaceName(LOGICAL_IF_NAME);
- dataPlaneLocatorBuilder.setLocatorType(liBuilder.build());
- sffDplBuilder.setDataPlaneLocator(dataPlaneLocatorBuilder.build());
- }
-
- if (createSffDpl) {
- List<SffDataPlaneLocator> sffDpls = new ArrayList<>();
- sffDplBuilder.withKey(new SffDataPlaneLocatorKey(new SffDataPlaneLocatorName(SFF_DPL_NAME)));
- sffDplBuilder.setName(new SffDataPlaneLocatorName(SFF_DPL_NAME));
- sffDpls.add(sffDplBuilder.build());
- sffBuilder.setSffDataPlaneLocator(sffDpls);
- }
-
- if (createSff) {
- sffBuilder.setName(sffName);
- storeSff(sffName, sffBuilder.build());
- }
-
- return rspBuilder;
- }
-
- @SuppressWarnings("deprecation")
- private void storeRsp(RspName rspName, RenderedServicePath rsp) {
- InstanceIdentifier<RenderedServicePath> rspIid = InstanceIdentifier.builder(RenderedServicePaths.class)
- .child(RenderedServicePath.class, new RenderedServicePathKey(rspName)).build();
-
- MDSALUtil.syncWrite(getDataBroker(), LogicalDatastoreType.OPERATIONAL, rspIid, rsp);
- }
-
- @SuppressWarnings("deprecation")
- private void storeSff(SffName sffName, ServiceFunctionForwarder sff) {
- InstanceIdentifier<ServiceFunctionForwarder> sffIid;
- sffIid = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
- .child(ServiceFunctionForwarder.class, new ServiceFunctionForwarderKey(sffName))
- .build();
-
- MDSALUtil.syncWrite(getDataBroker(), LogicalDatastoreType.CONFIGURATION, sffIid, sff);
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.opendaylight.yangtools.testutils.mockito.MoreAnswers.realOrException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.mockito.Mockito;
-import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey;
-import org.opendaylight.yangtools.yang.common.Uint64;
-
-public abstract class TestInterfaceManager implements IInterfaceManager {
- public static TestInterfaceManager newInstance() {
- return Mockito.mock(TestInterfaceManager.class, realOrException());
- }
-
- @Override
- public List<OvsdbTerminationPointAugmentation> getTunnelPortsOnBridge(Uint64 dpnId) {
- if (GeniusProviderTestParams.DPN_ID_NO_EXIST.equals(dpnId.toJava())) {
- // Unfortunately, the getTunnelPortsOnBridge() method may return null
- return null;
- }
-
- if (GeniusProviderTestParams.DPN_ID_NO_PORTS.equals(dpnId.toJava())) {
- return Collections.emptyList();
- }
-
- OvsdbTerminationPointAugmentationBuilder tpAug = new OvsdbTerminationPointAugmentationBuilder();
- tpAug.setOfport(GeniusProviderTestParams.OF_PORT);
-
- if (GeniusProviderTestParams.DPN_ID_NO_VXGPE_PORTS.equals(dpnId.toJava())) {
- // Tunnel Termination Point that is NOT of type VXGPE
- tpAug.setInterfaceType(InterfaceTypeGre.class);
- } else {
- // Tunnel Termination Point that IS of type VXGPE
- tpAug.setInterfaceType(InterfaceTypeVxlan.class);
- }
-
- List<Options> opsList = new ArrayList<>();
- if (!GeniusProviderTestParams.DPN_ID_NO_OPTIONS.equals(dpnId.toJava())) {
- OptionsBuilder opsBuilder = new OptionsBuilder();
- opsBuilder.withKey(new OptionsKey(GeniusProvider.OPTION_KEY_REMOTE_IP));
- opsBuilder.setValue(GeniusProvider.OPTION_VALUE_FLOW);
- opsList.add(opsBuilder.build());
- }
- tpAug.setOptions(opsList);
-
- List<OvsdbTerminationPointAugmentation> tpAugList = new ArrayList<>();
- tpAugList.add(tpAug.build());
-
- return tpAugList;
- }
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.providers;
-
-import static org.opendaylight.yangtools.testutils.mockito.MoreAnswers.realOrException;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.mockito.Mockito;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-public abstract class TestOdlInterfaceRpcService implements OdlInterfaceRpcService {
- public static TestOdlInterfaceRpcService newInstance() {
- return Mockito.mock(TestOdlInterfaceRpcService.class, realOrException());
- }
-
- @Override
- public ListenableFuture<RpcResult<GetEndpointIpForDpnOutput>> getEndpointIpForDpn(GetEndpointIpForDpnInput input) {
- BigInteger dpnId = input.getDpid().toJava();
-
- // if the dpnId is DPN_ID_NO_EXIST, then an empty response will be returned
- GetEndpointIpForDpnOutputBuilder builder = new GetEndpointIpForDpnOutputBuilder();
- if (GeniusProviderTestParams.DPN_ID.equals(dpnId)) {
- List<IpAddress> localIpList = new ArrayList<>();
- localIpList.add(new IpAddress(new Ipv4Address(GeniusProviderTestParams.IPV4_ADDRESS_STR)));
- builder.setLocalIps(localIpList);
- } else if (dpnId == GeniusProviderTestParams.DPN_ID_INVALID) {
- return RpcResultBuilder.<GetEndpointIpForDpnOutput>failed()
- .withError(ErrorType.APPLICATION, "Invalid data.").buildFuture();
- }
-
- return RpcResultBuilder.success(builder.build()).buildFuture();
- }
-
- @Override
- public ListenableFuture<RpcResult<GetDpidFromInterfaceOutput>> getDpidFromInterface(
- GetDpidFromInterfaceInput input) {
- String ifName = input.getIntfName();
-
- // if the ifName is INTERFACE_NAME_NO_EXIST, then an empty response will be returned
- GetDpidFromInterfaceOutputBuilder builder = new GetDpidFromInterfaceOutputBuilder();
- if (ifName == GeniusProviderTestParams.INTERFACE_NAME) {
- builder.setDpid(GeniusProviderTestParams.DPN_ID);
- } else if (ifName == GeniusProviderTestParams.INTERFACE_NAME_INVALID) {
- return RpcResultBuilder.<GetDpidFromInterfaceOutput>failed()
- .withError(ErrorType.APPLICATION, "Invalid data.").buildFuture();
- }
-
- return RpcResultBuilder.success(builder.build()).buildFuture();
- }
-
- @Override
- public ListenableFuture<RpcResult<GetNodeconnectorIdFromInterfaceOutput>>
- getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
- String ifName = input.getIntfName();
-
- // if the ifName is INTERFACE_NAME_NO_EXIST, then an empty response will be returned
- GetNodeconnectorIdFromInterfaceOutputBuilder builder = new GetNodeconnectorIdFromInterfaceOutputBuilder();
- if (ifName == GeniusProviderTestParams.INTERFACE_NAME) {
- builder.setNodeconnectorId(new NodeConnectorId(
- GeniusProviderTestParams.NODE_CONNECTOR_ID_PREFIX
- + GeniusProviderTestParams.INTERFACE_NAME));
- } else if (ifName == GeniusProviderTestParams.INTERFACE_NAME_INVALID) {
- return RpcResultBuilder.<GetNodeconnectorIdFromInterfaceOutput>failed()
- .withError(ErrorType.APPLICATION, "Invalid data.").buildFuture();
- }
-
- return RpcResultBuilder.success(builder.build()).buildFuture();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.AceType;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEthBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ClassifierEntryTest {
-
- @Mock
- private ClassifierEntryRenderer renderer;
-
- @Test
- public void equalsContract() throws Exception {
- new EqualsTester()
- .addEqualityGroup(buildIngressEntry(), buildIngressEntry())
- .addEqualityGroup(buildNodeEntry(), buildNodeEntry())
- .addEqualityGroup(buildMatchEntry(), buildMatchEntry())
- .addEqualityGroup(buildPathEntry(), buildPathEntry())
- .addEqualityGroup(buildEgressEntry(), buildEgressEntry())
- .testEquals();
- }
-
- private ClassifierEntry buildIngressEntry() {
- return ClassifierEntry.buildIngressEntry(new InterfaceKey("input"));
- }
-
- private ClassifierEntry buildEgressEntry() {
- return ClassifierEntry.buildEgressEntry(new InterfaceKey("output"), "127.0.0.1");
- }
-
- private ClassifierEntry buildNodeEntry() {
- return ClassifierEntry.buildNodeEntry(new NodeId("node"));
- }
-
- private ClassifierEntry buildPathEntry() {
- return ClassifierEntry.buildPathEntry(new NodeId("node"), 100L, (short) 254, (short) 253, "127.0.0.10");
- }
-
- private ClassifierEntry buildMatchEntry() {
- AceType aceType = new AceEthBuilder()
- .setDestinationMacAddress(new MacAddress("12:34:56:78:90:AB"))
- .build();
- Matches matches = new MatchesBuilder().setAceType(aceType).build();
- return ClassifierEntry.buildMatchEntry(
- new NodeId("node"),
- "connector",
- matches,
- 100L,
- (short) 254);
- }
-
- @Test
- public void renderIngressEntry() throws Exception {
- InterfaceKey interfaceKey = new InterfaceKey("interface");
- ClassifierEntry entry = ClassifierEntry.buildIngressEntry(interfaceKey);
- entry.render(renderer);
- verify(renderer).renderIngress(interfaceKey);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void renderEgressEntry() throws Exception {
- InterfaceKey interfaceKey = new InterfaceKey("interface");
- ClassifierEntry entry = ClassifierEntry.buildEgressEntry(interfaceKey, "127.0.0.1");
- entry.render(renderer);
- verify(renderer).renderEgress(interfaceKey, "127.0.0.1");
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void renderNodeEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- ClassifierEntry entry = ClassifierEntry.buildNodeEntry(nodeId);
- entry.render(renderer);
- verify(renderer).renderNode(nodeId);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void renderPathEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- Long nsp = 2L;
- short nsi = (short) 254;
- short nsl = (short) 252;
- String firstHopIp = "127.0.0.1";
- ClassifierEntry entry = ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, firstHopIp);
- entry.render(renderer);
- verify(renderer).renderPath(nodeId, nsp, nsi, nsl, firstHopIp);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void renderMatchEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- String connector = "openflow:0123456789:1";
- Long nsp = 2L;
- Short nsi = (short) 254;
- Matches matches = new MatchesBuilder().build();
- ClassifierEntry entry = ClassifierEntry.buildMatchEntry(nodeId, connector, matches, nsp, nsi);
- entry.render(renderer);
- verify(renderer).renderMatch(nodeId, connector, matches, nsp, nsi);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void suppressIngressEntry() throws Exception {
- InterfaceKey interfaceKey = new InterfaceKey("interface");
- ClassifierEntry entry = ClassifierEntry.buildIngressEntry(interfaceKey);
- entry.suppress(renderer);
- verify(renderer).suppressIngress(interfaceKey);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void suppressEgressEntry() throws Exception {
- InterfaceKey interfaceKey = new InterfaceKey("interface");
- ClassifierEntry entry = ClassifierEntry.buildEgressEntry(interfaceKey, "127.0.0.1");
- entry.suppress(renderer);
- verify(renderer).suppressEgress(interfaceKey, "127.0.0.1");
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void suppressNodeEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- ClassifierEntry entry = ClassifierEntry.buildNodeEntry(nodeId);
- entry.suppress(renderer);
- verify(renderer).suppressNode(nodeId);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void suppressPathEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- Long nsp = 2L;
- short nsi = (short) 254;
- short nsl = (short) 252;
- String firstHopIp = "127.0.0.1";
- ClassifierEntry entry = ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, firstHopIp);
- entry.suppress(renderer);
- verify(renderer).suppressPath(nodeId, nsp, nsi, nsl, firstHopIp);
- verifyNoMoreInteractions(renderer);
- }
-
- @Test
- public void suppressMatchEntry() throws Exception {
- NodeId nodeId = new NodeId("node");
- String connector = "openflow:0123456789:1";
- Long nsp = 2L;
- Short nsi = (short) 254;
- Matches matches = new MatchesBuilder().build();
- ClassifierEntry entry = ClassifierEntry.buildMatchEntry(nodeId, connector, matches, nsp, nsi);
- entry.suppress(renderer);
- verify(renderer).suppressMatch(nodeId, connector, matches, nsp, nsi);
- verifyNoMoreInteractions(renderer);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.service.domain.impl;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.internal.util.collections.Sets;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.ClassifierEntry;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer;
-import org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ClassifierUpdateTest {
-
- @Mock
- private ClassifierEntryRenderer rendererA;
-
- @Mock
- private ClassifierEntryRenderer rendererB;
-
- @Mock
- private ClassifierState configurationState;
-
- @Mock
- private ClassifierState operationalState;
-
- private ClassifierUpdate classifierUpdate;
-
- @Before
- public void setup() {
- classifierUpdate = new ClassifierUpdate(
- configurationState,
- operationalState,
- Arrays.asList(rendererA, rendererB));
- }
-
- @Test
- public void update() throws Exception {
- ClassifierEntry configOnly = ClassifierEntry.buildIngressEntry(new InterfaceKey("configOnly"));
- ClassifierEntry operOnly = ClassifierEntry.buildIngressEntry(new InterfaceKey("operOnly"));
- ClassifierEntry configAndOper = ClassifierEntry.buildIngressEntry(new InterfaceKey("configAndOper"));
- when(configurationState.getAllEntries()).thenReturn(Sets.newSet(configOnly, configAndOper));
- when(operationalState.getAllEntries()).thenReturn(Sets.newSet(configAndOper, operOnly));
- classifierUpdate.run();
- verify(rendererA).renderIngress(new InterfaceKey("configOnly"));
- verify(rendererB).renderIngress(new InterfaceKey("configOnly"));
- verify(rendererA).suppressIngress(new InterfaceKey("operOnly"));
- verify(rendererB).suppressIngress(new InterfaceKey("operOnly"));
- verifyNoMoreInteractions(rendererA);
- verifyNoMoreInteractions(rendererB);
- }
-
-}
+++ /dev/null
-/*
- * Copyright © 2017 Ericsson, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.genius.mdsalutil.packet.IPProtocols;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEthBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRange;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRange;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.dst.grouping.NxmOfTcpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.src.grouping.NxmOfTcpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.dst.grouping.NxmOfUdpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrc;
-import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint8;
-
-public class AclMatchesTest {
-
- private static final String MAC_SRC_STR = "11:22:33:44:55:66";
- private static final String MAC_DST_STR = "66:55:44:33:22:11";
- private static final String IPV4_DST_STR = "10.1.2.0/24";
- private static final String IPV4_SRC_STR = "10.1.2.3/32";
- private static final String IPV6_DST_STR = "2001:DB8:AC10:FE01::/64";
- private static final String IPV6_SRC_STR = "2001:db8:85a3:7334::/64";
- private static final int TCP_SRC_LOWER_PORT = 80;
- private static final int TCP_SRC_UPPER_PORT = 82;
- private static final int TCP_DST_LOWER_PORT = 800;
- private static final int TCP_DST_UPPER_PORT = 800;
- private static final int UDP_SRC_LOWER_PORT = 90;
- private static final int UDP_SRC_UPPER_PORT = 90;
- private static final int UDP_DST_LOWER_PORT = 900;
- private static final int UDP_DST_UPPER_PORT = 902;
- private static final short DSCP_VALUE = (short) 42;
-
-
- @Test
- public void buildEthMatchTest() {
- AceEthBuilder aceEthBuilder = new AceEthBuilder();
- aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
- aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceEthBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // The ethernet match should be there with src/dst values
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetSource().getAddress().getValue(), MAC_SRC_STR);
- assertEquals(ethMatch.getEthernetDestination().getAddress().getValue(), MAC_DST_STR);
-
- // The rest should be null
- assertNull(matchBuilder.getIpMatch());
- assertNull(matchBuilder.getLayer3Match());
- assertNull(matchBuilder.getLayer4Match());
- }
- }
-
- @Test
- public void buildIpv4MatchTest() {
- AceIpv4Builder aceIpv4 = new AceIpv4Builder();
- aceIpv4.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
- aceIpv4.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
-
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(aceIpv4.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // The layer3 match should be there with src/dst values
- Ipv4Match l3 = (Ipv4Match) matchBuilder.getLayer3Match();
- assertNotNull(l3);
- assertEquals(l3.getIpv4Destination().getValue().toString(), IPV4_DST_STR);
- assertEquals(l3.getIpv4Source().getValue().toString(), IPV4_SRC_STR);
-
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // The rest should be null
- assertNull(matchBuilder.getIpMatch());
- assertNull(matchBuilder.getLayer4Match());
- }
- assertEquals(1, matchBuilds.size());
- }
-
- @Test
- public void buildIpv4SrcLwrTcpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(TCP_SRC_LOWER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> srcTcpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its TCP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.TCP.shortValue()));
-
- NxmOfTcpSrc tcpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpSrc();
-
-
- if (tcpSrc != null) {
- srcTcpMatches.add(tcpSrc.getPort().getValue().toJava());
- srcTcpMatches.add(tcpSrc.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, srcTcpMatches.size());
- assertTrue(srcTcpMatches.contains(TCP_SRC_LOWER_PORT));
- assertTrue(srcTcpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4SrcTcpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(TCP_SRC_LOWER_PORT));
- srcPortRange.setUpperPort(new PortNumber(TCP_SRC_UPPER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> srcTcpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its TCP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.TCP.shortValue()));
-
- NxmOfTcpSrc tcpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpSrc();
-
-
- if (tcpSrc != null) {
- srcTcpMatches.add(tcpSrc.getPort().getValue().toJava());
- srcTcpMatches.add(tcpSrc.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(2, matchBuilds.size());
- assertEquals(4, srcTcpMatches.size());
- assertTrue(srcTcpMatches.contains(TCP_SRC_LOWER_PORT));
- assertTrue(srcTcpMatches.contains(TCP_SRC_UPPER_PORT));
- assertTrue(srcTcpMatches.contains(65535));
- assertTrue(srcTcpMatches.contains(65534));
- }
-
- @Test
- public void buildIpv4DstLwrTcpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(TCP_DST_LOWER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> dstTcpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its TCP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.TCP.shortValue()));
-
- NxmOfTcpDst tcpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpDst();
-
- if (tcpDst != null) {
- dstTcpMatches.add(tcpDst.getPort().getValue().toJava());
- dstTcpMatches.add(tcpDst.getMask().toJava());
- }
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, dstTcpMatches.size());
- assertTrue(dstTcpMatches.contains(TCP_DST_LOWER_PORT));
- assertTrue(dstTcpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4DstTcpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(TCP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(TCP_DST_UPPER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> dstTcpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its TCP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.TCP.shortValue()));
-
- NxmOfTcpDst tcpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpDst();
-
- if (tcpDst != null) {
- dstTcpMatches.add(tcpDst.getPort().getValue().toJava());
- dstTcpMatches.add(tcpDst.getMask().toJava());
- }
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, dstTcpMatches.size());
- assertTrue(dstTcpMatches.contains(TCP_DST_LOWER_PORT));
- assertTrue(dstTcpMatches.contains(TCP_DST_UPPER_PORT));
- assertTrue(dstTcpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4TcpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(TCP_SRC_LOWER_PORT));
- srcPortRange.setUpperPort(new PortNumber(TCP_SRC_UPPER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(TCP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(TCP_DST_UPPER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> dstTcpMatches = new HashSet<>();
- Set<Integer> srcTcpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its TCP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.TCP.shortValue()));
-
- NxmOfTcpSrc tcpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpSrc();
-
- NxmOfTcpDst tcpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(1)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfTcpDst();
-
- if (tcpSrc != null) {
- srcTcpMatches.add(tcpSrc.getPort().getValue().toJava());
- srcTcpMatches.add(tcpSrc.getMask().toJava());
- }
-
- if (tcpDst != null) {
- dstTcpMatches.add(tcpDst.getPort().getValue().toJava());
- dstTcpMatches.add(tcpDst.getMask().toJava());
- }
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(2, matchBuilds.size());
- assertEquals(4, srcTcpMatches.size());
- assertEquals(2, dstTcpMatches.size());
-
- assertTrue(srcTcpMatches.contains(TCP_SRC_LOWER_PORT));
- assertTrue(srcTcpMatches.contains(TCP_SRC_UPPER_PORT));
- assertTrue(srcTcpMatches.contains(65535));
- assertTrue(srcTcpMatches.contains(65534));
-
- assertTrue(dstTcpMatches.contains(TCP_DST_LOWER_PORT));
- assertTrue(dstTcpMatches.contains(TCP_DST_UPPER_PORT));
- assertTrue(dstTcpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4SrcLwrUdpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(UDP_SRC_LOWER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> srcUdpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its UDP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.UDP.shortValue()));
-
- NxmOfUdpSrc udpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpSrc();
-
- if (udpSrc != null) {
- srcUdpMatches.add(udpSrc.getPort().getValue().toJava());
- srcUdpMatches.add(udpSrc.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, srcUdpMatches.size());
- assertTrue(srcUdpMatches.contains(UDP_SRC_LOWER_PORT));
- assertTrue(srcUdpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4SrcUdpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(UDP_SRC_LOWER_PORT));
- srcPortRange.setUpperPort(new PortNumber(UDP_SRC_UPPER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> srcUdpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its UDP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.UDP.shortValue()));
-
- NxmOfUdpSrc udpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpSrc();
-
- if (udpSrc != null) {
- srcUdpMatches.add(udpSrc.getPort().getValue().toJava());
- srcUdpMatches.add(udpSrc.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, srcUdpMatches.size());
- assertTrue(srcUdpMatches.contains(UDP_SRC_LOWER_PORT));
- assertTrue(srcUdpMatches.contains(UDP_SRC_UPPER_PORT));
- assertTrue(srcUdpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4DstLwrUdpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> dstUdpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its UDP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.UDP.shortValue()));
-
- NxmOfUdpDst udpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpDst();
-
- if (udpDst != null) {
- dstUdpMatches.add(udpDst.getPort().getValue().toJava());
- dstUdpMatches.add(udpDst.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(1, matchBuilds.size());
- assertEquals(2, dstUdpMatches.size());
- assertTrue(dstUdpMatches.contains(UDP_DST_LOWER_PORT));
- assertTrue(dstUdpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4DstUdpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(UDP_DST_UPPER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> dstUdpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its UDP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.UDP.shortValue()));
-
- NxmOfUdpDst udpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpDst();
-
- if (udpDst != null) {
- dstUdpMatches.add(udpDst.getPort().getValue().toJava());
- dstUdpMatches.add(udpDst.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(2, matchBuilds.size());
- assertEquals(4, dstUdpMatches.size());
- assertTrue(dstUdpMatches.contains(UDP_DST_LOWER_PORT));
- assertTrue(dstUdpMatches.contains(UDP_DST_UPPER_PORT));
- assertTrue(dstUdpMatches.contains(65534));
- assertTrue(dstUdpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4UdpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(UDP_SRC_LOWER_PORT));
- srcPortRange.setUpperPort(new PortNumber(UDP_SRC_UPPER_PORT));
- aceIpBuilder.setSourcePortRange(srcPortRange.build());
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(UDP_DST_UPPER_PORT));
- aceIpBuilder.setDestinationPortRange(dstPortRange.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- Set<Integer> srcUdpMatches = new HashSet<>();
- Set<Integer> dstUdpMatches = new HashSet<>();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Make sure its UDP
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpProtocol(), Uint8.valueOf(IPProtocols.UDP.shortValue()));
-
- NxmOfUdpSrc udpSrc = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(0)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpSrc();
-
- NxmOfUdpDst udpDst = matchBuilder
- .augmentation(GeneralAugMatchNodesNodeTableFlow.class).getExtensionList().get(1)
- .getExtension().augmentation(NxAugMatchNodesNodeTableFlow.class).getNxmOfUdpDst();
-
- if (udpSrc != null) {
- srcUdpMatches.add(udpSrc.getPort().getValue().toJava());
- srcUdpMatches.add(udpSrc.getMask().toJava());
- }
-
- if (udpDst != null) {
- dstUdpMatches.add(udpDst.getPort().getValue().toJava());
- dstUdpMatches.add(udpDst.getMask().toJava());
- }
-
- // The layer3 match should be null
- assertNull(matchBuilder.getLayer3Match());
- }
- assertEquals(2, matchBuilds.size());
- assertEquals(2, srcUdpMatches.size());
- assertEquals(4, dstUdpMatches.size());
-
- assertTrue(srcUdpMatches.contains(UDP_SRC_LOWER_PORT));
- assertTrue(srcUdpMatches.contains(UDP_SRC_UPPER_PORT));
- assertTrue(srcUdpMatches.contains(65535));
-
- assertTrue(dstUdpMatches.contains(UDP_DST_LOWER_PORT));
- assertTrue(dstUdpMatches.contains(UDP_DST_UPPER_PORT));
- assertTrue(dstUdpMatches.contains(65534));
- assertTrue(dstUdpMatches.contains(65535));
- }
-
- @Test
- public void buildIpv4DscpMatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
- aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // There should be an IPv4 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV4));
-
- // Check the DSCP value
- IpMatch ipMatch = matchBuilder.getIpMatch();
- assertNotNull(ipMatch);
- assertEquals(ipMatch.getIpDscp().getValue(), Uint8.valueOf(DSCP_VALUE));
-
- // The rest should be null
- assertNull(matchBuilder.getLayer3Match());
- assertNull(matchBuilder.getLayer4Match());
- }
- }
-
- @Test
- public void buildIpv6MatchTest() {
- AceIpv6Builder aceIpv6 = new AceIpv6Builder();
- aceIpv6.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
- aceIpv6.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
-
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setAceIpVersion(aceIpv6.build());
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
-
- // Create the aclMatches that is the object to be tested
- AclMatches aclMatches = new AclMatches(matchesBuilder.build());
- List<MatchBuilder> matchBuilds = aclMatches.buildMatch();
-
- for (MatchBuilder matchBuilder : matchBuilds) {
- // The layer3 match should be there with src/dst values
- Ipv6Match l3 = (Ipv6Match) matchBuilder.getLayer3Match();
- assertNotNull(l3);
- assertEquals(l3.getIpv6Destination().getValue().toString(), IPV6_DST_STR);
- assertEquals(l3.getIpv6Source().getValue().toString(), IPV6_SRC_STR);
-
- // There should be an IPv6 etherType set
- EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
- assertNotNull(ethMatch);
- assertEquals(ethMatch.getEthernetType().getType().getValue(), Uint32.valueOf(NwConstants.ETHTYPE_IPV6));
-
- // The rest should be null
- assertNull(matchBuilder.getIpMatch());
- assertNull(matchBuilder.getLayer4Match());
- }
- }
-
- @Test
- public void invertEthMatchTest() {
- AceEthBuilder aceEthBuilder = new AceEthBuilder();
- aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
- aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
- AceEth aceEth = aceEthBuilder.build();
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceEth);
- Matches matches = matchesBuilder.build();
-
- Matches invertedMatches = AclMatches.invertMatches(matches);
-
- assertNotEquals(matches, invertedMatches);
-
- AceEth invertedAceEth = (AceEth) invertedMatches.getAceType();
- assertEquals(invertedAceEth.getDestinationMacAddress(), aceEth.getSourceMacAddress());
- assertEquals(invertedAceEth.getSourceMacAddress(), aceEth.getDestinationMacAddress());
- }
-
- @Test
- public void invertIpv4MatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
- aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(UDP_DST_UPPER_PORT));
- DestinationPortRange destinationPortRange = dstPortRange.build();
- aceIpBuilder.setDestinationPortRange(destinationPortRange);
-
- AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
- aceIpv4Builder.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
- aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
- AceIpv4 aceIpv4 = aceIpv4Builder.build();
- aceIpBuilder.setAceIpVersion(aceIpv4);
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- AceIp aceIp = aceIpBuilder.build();
- matchesBuilder.setAceType(aceIp);
-
- Matches matches = matchesBuilder.build();
-
- Matches invertedMatches = AclMatches.invertMatches(matches);
-
- assertNotEquals(matches, invertedMatches);
-
- AceIp invertedAceIp = (AceIp) invertedMatches.getAceType();
- assertEquals(invertedAceIp.getDscp(), aceIp.getDscp());
- assertEquals(invertedAceIp.getProtocol(), aceIp.getProtocol());
-
- DestinationPortRange invertedDestinationPortRange = invertedAceIp.getDestinationPortRange();
- assertNull(invertedDestinationPortRange);
-
- SourcePortRange invertedSourcePortRange = invertedAceIp.getSourcePortRange();
- assertEquals(invertedSourcePortRange.getLowerPort(), destinationPortRange.getLowerPort());
- assertEquals(invertedSourcePortRange.getUpperPort(), destinationPortRange.getUpperPort());
-
- AceIpv4 invertedAceIpv4 = (AceIpv4) invertedAceIp.getAceIpVersion();
- assertEquals(invertedAceIpv4.getDestinationIpv4Network(), aceIpv4.getSourceIpv4Network());
- assertEquals(invertedAceIpv4.getSourceIpv4Network(), aceIpv4.getDestinationIpv4Network());
- }
-
- @Test
- public void invertIpv6MatchTest() {
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- aceIpBuilder.setProtocol(IPProtocols.TCP.shortValue());
- aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
-
- SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
- srcPortRange.setLowerPort(new PortNumber(TCP_SRC_LOWER_PORT));
- srcPortRange.setUpperPort(new PortNumber(TCP_SRC_UPPER_PORT));
- SourcePortRange sourcePortRange = srcPortRange.build();
- aceIpBuilder.setSourcePortRange(sourcePortRange);
-
- DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
- dstPortRange.setLowerPort(new PortNumber(TCP_DST_LOWER_PORT));
- dstPortRange.setUpperPort(new PortNumber(TCP_DST_UPPER_PORT));
- DestinationPortRange destinationPortRange = dstPortRange.build();
- aceIpBuilder.setDestinationPortRange(destinationPortRange);
-
- AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
- aceIpv6Builder.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
- aceIpv6Builder.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
- AceIpv6 aceIpv6 = aceIpv6Builder.build();
- aceIpBuilder.setAceIpVersion(aceIpv6);
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- AceIp aceIp = aceIpBuilder.build();
- matchesBuilder.setAceType(aceIp);
-
- Matches matches = matchesBuilder.build();
-
- Matches invertedMatches = AclMatches.invertMatches(matches);
-
- assertNotEquals(matches, invertedMatches);
-
- AceIp invertedAceIp = (AceIp) invertedMatches.getAceType();
- assertEquals(invertedAceIp.getDscp(), aceIp.getDscp());
- assertEquals(invertedAceIp.getProtocol(), aceIp.getProtocol());
-
- DestinationPortRange invertedDestinationPortRange = invertedAceIp.getDestinationPortRange();
- assertEquals(invertedDestinationPortRange.getLowerPort(), sourcePortRange.getLowerPort());
- assertEquals(invertedDestinationPortRange.getUpperPort(), sourcePortRange.getUpperPort());
-
- SourcePortRange invertedSourcePortRange = invertedAceIp.getSourcePortRange();
- assertEquals(invertedSourcePortRange.getLowerPort(), destinationPortRange.getLowerPort());
- assertEquals(invertedSourcePortRange.getUpperPort(), destinationPortRange.getUpperPort());
-
- AceIpv6 invertedAceIpv6 = (AceIpv6) invertedAceIp.getAceIpVersion();
- assertEquals(invertedAceIpv6.getDestinationIpv6Network(), aceIpv6.getSourceIpv6Network());
- assertEquals(invertedAceIpv6.getSourceIpv6Network(), aceIpv6.getDestinationIpv6Network());
- }
-
- @Test
- public void testgetLayer4MaskForRange_SinglePort() {
- Map<Integer, Integer> layer4MaskForRange = AclMatches.getLayer4MaskForRange(1111, 1111);
- assertEquals("port L4 mask missing", 1, layer4MaskForRange.size());
- }
-
- @Test
- public void testgetLayer4MaskForRange_MultiplePorts() {
- Map<Integer, Integer> layer4MaskForRange = AclMatches.getLayer4MaskForRange(1024, 2048);
- assertEquals("port L4 mask missing", 2, layer4MaskForRange.size());
- }
-
- @Test
- public void testgetLayer4MaskForRange_IllegalPortRange_ExceedMin() {
- Map<Integer, Integer> layer4MaskForRange = AclMatches.getLayer4MaskForRange(0, 1);
-
- assertEquals("port L4 mask missing", 1, layer4MaskForRange.size());
- }
-
- @Test
- public void testgetLayer4MaskForRange_IllegalPortRange_ExceedMax() {
- Map<Integer, Integer> layer4MaskForRange = AclMatches.getLayer4MaskForRange(1, 65536);
- assertEquals("Illegal ports range", 0, layer4MaskForRange.size());
- }
-
- @Test
- public void testgetLayer4MaskForRange_IllegalPortRange_MinGreaterThanMax() {
- Map<Integer, Integer> layer4MaskForRange = AclMatches.getLayer4MaskForRange(8192, 4096);
- assertEquals("Illegal ports range", 0, layer4MaskForRange.size());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Ericsson Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.classifier.utils;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.atMost;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionException;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LastTaskExecutorTest {
-
- @Mock
- private Executor executor;
-
- @Mock
- private Runnable runnable;
-
- @Captor
- private ArgumentCaptor<Runnable> runnableArgumentCaptor;
-
- private LastTaskExecutor lastTaskExecutor;
-
- @Before
- public void setup() {
- lastTaskExecutor = new LastTaskExecutor(executor);
- }
-
- @Test
- public void executeTwoConsecutive() throws Exception {
- lastTaskExecutor.execute(runnable);
- lastTaskExecutor.execute(runnable);
- verify(executor, atMost(2)).execute(runnableArgumentCaptor.capture());
- runnableArgumentCaptor.getAllValues().forEach(Runnable::run);
- verify(runnable).run();
- }
-
- @Test
- public void executeTwoInterleaved() throws Exception {
- lastTaskExecutor.execute(runnable);
- verify(executor).execute(runnableArgumentCaptor.capture());
- runnableArgumentCaptor.getValue().run();
- lastTaskExecutor.execute(runnable);
- verify(executor,times(2)).execute(runnableArgumentCaptor.capture());
- runnableArgumentCaptor.getValue().run();
- verify(runnable, times(2)).run();
- }
-
- @Test(expected = NullPointerException.class)
- public void executeNull() throws Exception {
- lastTaskExecutor.execute(null);
- }
-
- @Test(expected = RejectedExecutionException.class)
- public void executeRejected() throws Exception {
- doThrow(new RejectedExecutionException()).when(executor).execute(any());
- lastTaskExecutor.execute(runnable);
- }
-
- @Test
- public void executeAfterRejected() throws Exception {
- doThrow(new RejectedExecutionException()).doNothing().when(executor).execute(any());
- try {
- lastTaskExecutor.execute(runnable);
- } catch (RejectedExecutionException e) {
- // noop
- }
- lastTaskExecutor.execute(runnable);
- verify(executor, times(2)).execute(any());
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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">
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>6.0.1</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netvirt</groupId>
- <artifactId>sfc.classifier</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <name>ODL :: netvirt :: ${project.artifactId}</name>
- <packaging>pom</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <modules>
- <module>api</module>
- <module>impl</module>
- </modules>
-
- <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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">
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>6.0.1</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netvirt</groupId>
- <artifactId>sfc</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <name>ODL :: netvirt :: ${project.artifactId}</name>
- <packaging>pom</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <modules>
- <module>classifier</module>
- <module>translator</module>
- </modules>
-
- <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<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.opendaylight.netvirt</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- <relativePath>../../commons/binding-parent</relativePath>
- </parent>
-
- <artifactId>sfc.translator</artifactId>
- <name>ODL :: netvirt :: ${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <properties>
- <sfc.version>0.11.0-SNAPSHOT</sfc.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.infrautils</groupId>
- <artifactId>inject</artifactId>
- <version>${infrautils.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-access-control-list</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sfc.classifier-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.neutron</groupId>
- <artifactId>model</artifactId>
- <version>${neutron.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-model</artifactId>
- <version>${sfc.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.sfc</groupId>
- <artifactId>sfc-provider</artifactId>
- <version>${sfc.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.genius</groupId>
- <artifactId>mdsalutil-api</artifactId>
- <version>${genius.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>blueprint-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.Collection;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Data-tree listener which delegates data processing to a {@link INeutronSfcDataProcessor}.
- */
-public abstract class DelegatingDataTreeListener<T extends DataObject> implements AutoCloseable,
- DataTreeChangeListener<T>,
- INeutronSfcDataProcessor<T> {
- private static final Logger LOG = LoggerFactory.getLogger(DelegatingDataTreeListener.class);
- private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder()
- .setNameFormat("NeutronSfcListener-%d").build();
- private final ExecutorService executorService = Executors.newFixedThreadPool(1, THREAD_FACTORY);
- private final INeutronSfcDataProcessor<T> dataProcessor;
- @Nullable
- private ListenerRegistration<DelegatingDataTreeListener<T>> listenerRegistration;
-
- public DelegatingDataTreeListener(DataBroker db, DataTreeIdentifier<T> treeId) {
- this.dataProcessor = Preconditions.checkNotNull(this, "Data processor can not be null!");
- registerListener(Preconditions.checkNotNull(db, "Data broker can not be null!"),
- Preconditions.checkNotNull(treeId, "Tree identifier can not be null!"));
- }
-
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
- private void registerListener(final DataBroker db, DataTreeIdentifier<T> treeId) {
- try {
- LOG.info("Registering Data Change Listener for {}", getClass().getSimpleName());
- listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
- } catch (final Exception e) {
- LOG.warn("{} DataChange listener registration fail!", getClass().getSimpleName(), e);
- throw new IllegalStateException("DataTreeListener startup fail! System needs restart.", e);
- }
- }
-
- private void processChanges(Collection<DataTreeModification<T>> changes) {
- LOG.info("onDataTreeChanged: Received Data Tree Changed {}", changes);
- for (DataTreeModification<T> change : changes) {
- final InstanceIdentifier<T> key = change.getRootPath().getRootIdentifier();
- final DataObjectModification<T> mod = change.getRootNode();
- LOG.info("onDataTreeChanged: Received Data Tree Changed Update of Type={} for Key={}",
- mod.getModificationType(), key);
- switch (mod.getModificationType()) {
- case DELETE:
- dataProcessor.remove(mod.getDataBefore());
- break;
- case SUBTREE_MODIFIED:
- dataProcessor.update(mod.getDataBefore(), mod.getDataAfter());
- break;
- case WRITE:
- if (mod.getDataBefore() == null) {
- dataProcessor.add(mod.getDataAfter());
- } else {
- dataProcessor.update(mod.getDataBefore(), mod.getDataAfter());
- }
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
- @Override
- public void onDataTreeChanged(@NonNull final Collection<DataTreeModification<T>> changes) {
- Preconditions.checkNotNull(changes, "Changes may not be null!");
- executorService.execute(() -> processChanges(changes));
- }
-
- @Override
- public void close() {
- if (listenerRegistration != null) {
- listenerRegistration.close();
- listenerRegistration = null;
- }
- executorService.shutdownNow();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * Neutron SFC yang model processor.
- */
-public interface INeutronSfcDataProcessor<D extends DataObject> {
-
- /**
- * Method removes DataObject which is identified by InstanceIdentifier.
- *
- * @param del - DataObject for removing
- */
- void remove(D del);
-
- /**
- * Method updates the original DataObject to the update DataObject.
- * Both are identified by same InstanceIdentifier.
- *
- * @param orig - original DataObject
- * @param update - changed DataObject (contain updates)*/
- void update(D orig, D update);
-
- /**
- * Method adds the DataObject which is identified by InstanceIdentifier
- * to device.
- *
- * @param add - new DataObject
- */
- void add(D add);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.SfcFlowClassifiers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifierKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortPairGroups;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPairKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility functions to read Neutron models (e.g network, subnet, port, sfc flow classifier
- * port pair, port group, port chain) from md-sal data store.
- */
-public class NeutronMdsalHelper {
- private static final Logger LOG = LoggerFactory.getLogger(NeutronMdsalHelper.class);
- private static final InstanceIdentifier<SfcFlowClassifiers> FC_IID =
- InstanceIdentifier.create(Neutron.class).child(SfcFlowClassifiers.class);
- private static final InstanceIdentifier<Ports> PORTS_IID =
- InstanceIdentifier.create(Neutron.class).child(Ports.class);
- private static final InstanceIdentifier<PortPairs> PORT_PAIRS_IID =
- InstanceIdentifier.create(Neutron.class).child(PortPairs.class);
- private static final InstanceIdentifier<PortPairGroups> PORT_PAIR_GROUPS_IID =
- InstanceIdentifier.create(Neutron.class).child(PortPairGroups.class);
-
- private final DataBroker dataBroker;
-
- public NeutronMdsalHelper(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- @Nullable
- public Port getNeutronPort(Uuid portId) {
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, getNeutronPortPath(portId)).orNull();
- }
-
- @Nullable
- public PortPair getNeutronPortPair(Uuid portPairId) {
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, getNeutronPortPairPath(portPairId)).orNull();
- }
-
- @Nullable
- public PortPairGroup getNeutronPortPairGroup(Uuid portPairGroupId) {
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, getNeutronPortPairGroupPath(portPairGroupId)).orNull();
- }
-
- @Nullable
- public SfcFlowClassifier getNeutronFlowClassifier(Uuid flowClassifierId) {
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, getNeutronSfcFlowClassifierPath(flowClassifierId)).orNull();
- }
-
- private InstanceIdentifier<Port> getNeutronPortPath(Uuid portId) {
- return PORTS_IID.builder().child(Port.class, new PortKey(portId)).build();
- }
-
- private InstanceIdentifier<PortPair> getNeutronPortPairPath(Uuid portPairId) {
- return PORT_PAIRS_IID.builder().child(PortPair.class, new PortPairKey(portPairId)).build();
- }
-
- private InstanceIdentifier<PortPairGroup> getNeutronPortPairGroupPath(Uuid portPairGroupId) {
- return PORT_PAIR_GROUPS_IID.builder().child(PortPairGroup.class, new PortPairGroupKey(portPairGroupId)).build();
- }
-
- private InstanceIdentifier<SfcFlowClassifier> getNeutronSfcFlowClassifierPath(Uuid portId) {
- return FC_IID.builder().child(SfcFlowClassifier.class, new SfcFlowClassifierKey(portId)).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.infrautils.inject.AbstractLifecycle;
-import org.opendaylight.netvirt.sfc.translator.flowclassifier.NeutronFlowClassifierListener;
-import org.opendaylight.netvirt.sfc.translator.portchain.NeutronPortChainListener;
-import org.opendaylight.netvirt.sfc.translator.portchain.NeutronPortPairGroupListener;
-import org.opendaylight.netvirt.sfc.translator.portchain.NeutronPortPairListener;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePathService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class OpenStackSFCTranslatorProvider extends AbstractLifecycle {
-
- private static final Logger LOG = LoggerFactory.getLogger(OpenStackSFCTranslatorProvider.class);
- private final DataBroker dataBroker;
- private final RenderedServicePathService rspService;
- private NeutronFlowClassifierListener neutronFlowClassifierListener;
- private NeutronPortPairListener neutronPortPairListener;
- private NeutronPortPairGroupListener neutronPortPairGroupListener;
- private NeutronPortChainListener neutronPortChainListener;
-
- @Inject
- public OpenStackSFCTranslatorProvider(final DataBroker dataBroker, final RenderedServicePathService rspService) {
- LOG.info("OpenStackSFCTranslatorProvider2 constructor");
- this.dataBroker = dataBroker;
- this.rspService = rspService;
- }
-
- @Override
- protected void start() {
- LOG.info("{} start", getClass().getSimpleName());
- neutronFlowClassifierListener = new NeutronFlowClassifierListener(dataBroker);
- neutronPortPairListener = new NeutronPortPairListener(dataBroker);
- neutronPortPairGroupListener = new NeutronPortPairGroupListener(dataBroker);
- neutronPortChainListener = new NeutronPortChainListener(dataBroker, rspService);
- if (this.rspService == null) {
- LOG.warn("RenderedServicePath Service is not available. Translation layer might not work as expected.");
- }
- }
-
- @Override
- protected void stop() {
- neutronFlowClassifierListener.close();
- neutronPortPairListener.close();
- neutronPortPairGroupListener.close();
- neutronPortChainListener.close();
- LOG.info("{} close", getClass().getSimpleName());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility methods to read OpenDaylight SFC models.
- */
-public class SfcMdsalHelper {
- private static final Logger LOG = LoggerFactory.getLogger(SfcMdsalHelper.class);
- private static final InstanceIdentifier<AccessLists> ACCESS_LIST_IID = InstanceIdentifier.create(AccessLists.class);
- private static final InstanceIdentifier<ServiceFunctions> SF_IID =
- InstanceIdentifier.create(ServiceFunctions.class);
- private static final InstanceIdentifier<ServiceFunctionForwarders> SFF_IID =
- InstanceIdentifier.create(ServiceFunctionForwarders.class);
- private static final InstanceIdentifier<ServiceFunctionChains> SFC_IID =
- InstanceIdentifier.create(ServiceFunctionChains.class);
- private static final InstanceIdentifier<ServiceFunctionPaths> SFP_IID
- = InstanceIdentifier.create(ServiceFunctionPaths.class);
- public static final String NETVIRT_LOGICAL_SFF_NAME = "Netvirt-Logical-SFF";
-
- private final DataBroker dataBroker;
-
- public SfcMdsalHelper(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- //ACL Flow Classifier data store utility methods
- public void addAclFlowClassifier(Acl aclFlowClassifier) {
- InstanceIdentifier<Acl> aclIid = getAclPath(aclFlowClassifier.key());
- LOG.info("Write ACL FlowClassifier {} to config data store at {}",aclFlowClassifier, aclIid);
- try {
- SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, aclIid,
- aclFlowClassifier);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", aclFlowClassifier, aclIid, e);
- }
- }
-
- public void updateAclFlowClassifier(Acl aclFlowClassifier) {
- InstanceIdentifier<Acl> aclIid = getAclPath(aclFlowClassifier.key());
- LOG.info("Update ACL FlowClassifier {} in config data store at {}",aclFlowClassifier, aclIid);
- try {
- SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, aclIid,
- aclFlowClassifier);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to merge {}", aclIid, e);
- }
- }
-
- public void removeAclFlowClassifier(Acl aclFlowClassifier) {
- InstanceIdentifier<Acl> aclIid = getAclPath(aclFlowClassifier.key());
- LOG.info("Remove ACL FlowClassifier {} from config data store at {}",aclFlowClassifier, aclIid);
- try {
- SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, aclIid);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {}", aclIid, e);
- }
- }
-
- //Service Function
- @Nullable
- public ServiceFunction readServiceFunction(ServiceFunctionKey sfKey) {
- InstanceIdentifier<ServiceFunction> sfIid = getSFPath(sfKey);
- LOG.info("Read Service Function {} from config data store at {}",sfKey, sfIid);
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, sfIid).orNull();
- }
-
- public void addServiceFunction(ServiceFunction sf) {
- InstanceIdentifier<ServiceFunction> sfIid = getSFPath(sf.key());
- LOG.info("Write Service Function {} to config data store at {}",sf, sfIid);
- try {
- SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, sfIid, sf);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", sf, sfIid, e);
- }
- }
-
- public void updateServiceFunction(ServiceFunction sf) {
- InstanceIdentifier<ServiceFunction> sfIid = getSFPath(sf.key());
- LOG.info("Update Service Function {} in config data store at {}",sf, sfIid);
- try {
- SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, sfIid, sf);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to merge {}", sfIid, e);
- }
- }
-
- public void removeServiceFunction(ServiceFunctionKey sfKey) {
- InstanceIdentifier<ServiceFunction> sfIid = getSFPath(sfKey);
- LOG.info("Remove Service Function {} from config data store at {}",sfKey, sfIid);
- try {
- SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, sfIid);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {}", sfIid, e);
- }
- }
-
- //Service Function Forwarder
- @Nullable
- public ServiceFunctionForwarder readServiceFunctionForwarder(ServiceFunctionForwarderKey sffKey) {
- InstanceIdentifier<ServiceFunctionForwarder> sffIid = getSFFPath(sffKey);
- LOG.info("Read Service Function Forwarder from config data store at {}", sffIid);
- return SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker,
- LogicalDatastoreType.CONFIGURATION, sffIid).orNull();
- }
-
- public void addServiceFunctionForwarder(ServiceFunctionForwarder sff) {
- InstanceIdentifier<ServiceFunctionForwarder> sffIid = getSFFPath(sff.key());
- LOG.info("Write Service Function Forwarder {} to config data store at {}",sff, sffIid);
- try {
- SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, sffIid, sff);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", sff, sffIid, e);
- }
- }
-
- public void updateServiceFunctionForwarder(ServiceFunctionForwarder sff) {
- InstanceIdentifier<ServiceFunctionForwarder> sffIid = getSFFPath(sff.key());
- LOG.info("Update Service Function Forwarder {} to config data store at {}",sff, sffIid);
- try {
- SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, sffIid, sff);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", sff, sffIid, e);
- }
- }
-
- public void deleteServiceFunctionForwarder(ServiceFunctionForwarderKey sffKey) {
- InstanceIdentifier<ServiceFunctionForwarder> sffIid = getSFFPath(sffKey);
- LOG.info("Delete Service Function Forwarder from config data store at {}", sffIid);
- try {
- SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, sffIid);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {}", sffIid, e);
- }
- }
-
- public void addServiceFunctionChain(ServiceFunctionChain sfc) {
- InstanceIdentifier<ServiceFunctionChain> sfcIid = getSFCPath(sfc.key());
- LOG.info("Write Service Function Chain {} to config data store at {}",sfc, sfcIid);
- try {
- SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, sfcIid, sfc);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", sfc, sfcIid, e);
- }
- }
-
- public void deleteServiceFunctionChain(ServiceFunctionChainKey sfcKey) {
- InstanceIdentifier<ServiceFunctionChain> sfcIid = getSFCPath(sfcKey);
- LOG.info("Remove Service Function Chain {} from config data store at {}",sfcKey, sfcIid);
- try {
- SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, sfcIid);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {}", sfcIid, e);
- }
- }
-
- public void addServiceFunctionPath(ServiceFunctionPath sfp) {
- InstanceIdentifier<ServiceFunctionPath> sfpIid = getSFPPath(sfp.key());
- LOG.info("Write Service Function Path {} to config data store at {}",sfp, sfpIid);
- try {
- SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, sfpIid, sfp);
- } catch (TransactionCommitFailedException e) {
- LOG.error("Error writing {} to {}", sfp, sfpIid, e);
- }
- }
-
- public void deleteServiceFunctionPath(ServiceFunctionPathKey sfpKey) {
- InstanceIdentifier<ServiceFunctionPath> sfpIid = getSFPPath(sfpKey);
- LOG.info("Delete Service Function Path from config data store at {}", sfpIid);
- try {
- SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, sfpIid);
- } catch (TransactionCommitFailedException e) {
- LOG.warn("Failed to delete {}", sfpIid, e);
- }
- }
-
- private static InstanceIdentifier<Acl> getAclPath(AclKey aclKey) {
- return ACCESS_LIST_IID.builder().child(Acl.class, aclKey).build();
- }
-
- private static InstanceIdentifier<ServiceFunction> getSFPath(ServiceFunctionKey key) {
- return SF_IID.builder().child(ServiceFunction.class, key).build();
- }
-
- private static InstanceIdentifier<ServiceFunctionForwarder> getSFFPath(ServiceFunctionForwarderKey key) {
- return SFF_IID.builder().child(ServiceFunctionForwarder.class, key).build();
- }
-
- private static InstanceIdentifier<ServiceFunctionChain> getSFCPath(ServiceFunctionChainKey key) {
- return SFC_IID.builder().child(ServiceFunctionChain.class, key).build();
- }
-
- private static InstanceIdentifier<ServiceFunctionPath> getSFPPath(ServiceFunctionPathKey key) {
- return SFP_IID.builder().child(ServiceFunctionPath.class, key).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.translator.flowclassifier;
-
-import java.util.ArrayList;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.Ipv4Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.Ipv6Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.AclKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntriesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.AceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.AceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.ActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRangeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPorts;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPortsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class will convert OpenStack Flow Classifier API yang models to
- * OpenDaylight ACL yang models.
- */
-public final class FlowClassifierTranslator {
- private static final Logger LOG = LoggerFactory.getLogger(FlowClassifierTranslator.class);
- private static final Short PROTO_TCP = 6;
- private static final Short PROTO_UDP = 17;
- private static final String RULE = "_rule";
-
- private FlowClassifierTranslator() {
-
- }
-
- public static Acl buildAcl(SfcFlowClassifier flowClassifier) {
- return buildAcl(flowClassifier, null);
- }
-
- public static Acl buildAcl(SfcFlowClassifier flowClassifier, @Nullable String sfpName) {
- LOG.info("OpenStack Networking SFC pushed Flow classifier : {}", flowClassifier);
- AclBuilder aclBuilder = new AclBuilder();
- AceBuilder aceBuilder = new AceBuilder();
-
- ActionsBuilder actionsBuilder = new ActionsBuilder();
- RedirectToSfcBuilder redirectToSfcBuilder = new RedirectToSfcBuilder();
- NeutronPortsBuilder neutronPortsBuilder = new NeutronPortsBuilder();
-
- AceIpBuilder aceIpBuilder = new AceIpBuilder();
- DestinationPortRangeBuilder destinationPortRange = new DestinationPortRangeBuilder();
- SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder();
-
- if (flowClassifier.getUuid() != null) {
- if (flowClassifier.getName() != null) {
- aclBuilder.setAclName(flowClassifier.getUuid().getValue() + "_" + flowClassifier.getName());
- } else {
- aclBuilder.setAclName(flowClassifier.getUuid().getValue());
- }
-
- }
- if (flowClassifier.getEthertype() != null) {
- IpPrefix sourceIp = null;
- IpPrefix destinationIp = null;
- if (flowClassifier.getSourceIpPrefix() != null) {
- sourceIp = flowClassifier.getSourceIpPrefix();
- }
- if (flowClassifier.getDestinationIpPrefix() != null) {
- destinationIp = flowClassifier.getDestinationIpPrefix();
- }
- if (flowClassifier.getEthertype() == EthertypeV4.class) {
- AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
- if (sourceIp != null && sourceIp.getIpv4Prefix() != null) {
- aceIpv4Builder.setSourceIpv4Network(sourceIp.getIpv4Prefix());
- }
- if (destinationIp != null && destinationIp.getIpv4Prefix() != null) {
- aceIpv4Builder.setDestinationIpv4Network(destinationIp.getIpv4Prefix());
- }
- aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
- aclBuilder.setAclType(Ipv4Acl.class);
- }
- if (flowClassifier.getEthertype() == EthertypeV6.class) {
- AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
- if (sourceIp != null && sourceIp.getIpv6Prefix() != null) {
- aceIpv6Builder.setSourceIpv6Network(sourceIp.getIpv6Prefix());
- }
- if (destinationIp != null && destinationIp.getIpv6Prefix() != null) {
- aceIpv6Builder.setDestinationIpv6Network(destinationIp.getIpv6Prefix());
- }
- aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
- aclBuilder.setAclType(Ipv6Acl.class);
- }
- }
- if (flowClassifier.getProtocol() != null) {
- if (flowClassifier.getProtocol() == ProtocolTcp.class) {
- aceIpBuilder.setProtocol(PROTO_TCP);
- }
- if (flowClassifier.getProtocol() == ProtocolUdp.class) {
- aceIpBuilder.setProtocol(PROTO_UDP);
- }
- }
- if (flowClassifier.getSourcePortRangeMin() != null) {
- sourcePortRangeBuilder.setLowerPort(new PortNumber(flowClassifier.getSourcePortRangeMin()));
- // set source port range only if lower port is specified as it is a mandatory parameter in acl model
- aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
- }
- if (flowClassifier.getSourcePortRangeMax() != null) {
- sourcePortRangeBuilder.setUpperPort(new PortNumber(flowClassifier.getSourcePortRangeMax()));
- aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
- }
- if (flowClassifier.getDestinationPortRangeMin() != null) {
- destinationPortRange.setLowerPort(new PortNumber(flowClassifier.getDestinationPortRangeMin()));
- // set destination port range only if lower port is specified as it is a mandatory parameter in acl model
- aceIpBuilder.setDestinationPortRange(destinationPortRange.build());
- }
- if (flowClassifier.getDestinationPortRangeMax() != null) {
- destinationPortRange.setUpperPort(new PortNumber(flowClassifier.getDestinationPortRangeMax()));
- aceIpBuilder.setDestinationPortRange(destinationPortRange.build());
- }
- if (flowClassifier.getLogicalSourcePort() != null) {
- neutronPortsBuilder.setSourcePortUuid(flowClassifier.getLogicalSourcePort().getValue());
- }
- if (flowClassifier.getLogicalDestinationPort() != null) {
- neutronPortsBuilder.setDestinationPortUuid(flowClassifier.getLogicalDestinationPort().getValue());
- }
-
- // currently not supported.
-// if (flowClassifier.getL7Parameter() != null) {
-// }
-
- MatchesBuilder matchesBuilder = new MatchesBuilder();
- matchesBuilder.setAceType(aceIpBuilder.build());
- matchesBuilder.addAugmentation(NeutronPorts.class, neutronPortsBuilder.build());
-
- //Set redirect-to-rsp action if rsp name is provided
- if (sfpName != null) {
- redirectToSfcBuilder.setSfpName(sfpName);
- actionsBuilder.addAugmentation(RedirectToSfc.class, redirectToSfcBuilder.build());
- aceBuilder.setActions(actionsBuilder.build());
- }
- aceBuilder.setMatches(matchesBuilder.build());
-
- //OpenStack networking-sfc don't pass action information
- //with flow classifier. It need to be determined using the
- //Port Chain data and then flow calssifier need to be updated
- //with the actions.
-
- aceBuilder.setRuleName(aclBuilder.getAclName() + RULE);
- aceBuilder.withKey(new AceKey(aceBuilder.getRuleName()));
-
- ArrayList<Ace> aceList = new ArrayList<>();
- aceList.add(aceBuilder.build());
- AccessListEntriesBuilder accessListEntriesBuilder = new AccessListEntriesBuilder();
- accessListEntriesBuilder.setAce(aceList);
-
- aclBuilder.setAccessListEntries(accessListEntriesBuilder.build());
- aclBuilder.withKey(new AclKey(aclBuilder.getAclName(),aclBuilder.getAclType()));
-
- LOG.info("Translated ACL Flow classfier : {}", aclBuilder.toString());
-
- return aclBuilder.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator.flowclassifier;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.sfc.translator.DelegatingDataTreeListener;
-import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.SfcFlowClassifiers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * OpenDaylight Neutron Flow Classifier yang models data change listener.
- */
-public class NeutronFlowClassifierListener extends DelegatingDataTreeListener<SfcFlowClassifier> {
-
- private static final InstanceIdentifier<SfcFlowClassifier> FLOW_CLASSIFIERS_IID =
- InstanceIdentifier.create(Neutron.class).child(SfcFlowClassifiers.class).child(SfcFlowClassifier.class);
-
- private final SfcMdsalHelper sfcMdsalHelper;
-
- public NeutronFlowClassifierListener(DataBroker db) {
- super(db, new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CLASSIFIERS_IID));
- sfcMdsalHelper = new SfcMdsalHelper(db);
-
- }
-
- /**
- * Method removes Acl respective to SfcFlowClassifier which is identified by InstanceIdentifier.
- *
- * @param deletedSfcFlowClassifier - SfcFlowClassifier for removing
- */
- @Override
- public void remove(SfcFlowClassifier deletedSfcFlowClassifier) {
- Acl aclFlowClassifier = FlowClassifierTranslator.buildAcl(deletedSfcFlowClassifier);
- sfcMdsalHelper.removeAclFlowClassifier(aclFlowClassifier);
- }
-
- /**
- * Method updates the original SfcFlowClassifier to the update SfcFlowClassifier.
- * Both are identified by same InstanceIdentifier.
- *
- * @param origSfcFlowClassifier - original SfcFlowClassifier
- * @param updatedSfcFlowClassifier - changed SfcFlowClassifier (contain updates)
- */
- @Override
- public void update(SfcFlowClassifier origSfcFlowClassifier, SfcFlowClassifier updatedSfcFlowClassifier) {
-
- Acl aclFlowClassifier = FlowClassifierTranslator.buildAcl(updatedSfcFlowClassifier);
- sfcMdsalHelper.updateAclFlowClassifier(aclFlowClassifier);
- }
-
- /**
- * Method adds the SfcFlowClassifier which is identified by InstanceIdentifier
- * to device.
- *
- * @param sfcFlowClassifier - new SfcFlowClassifier
- */
- @Override
- public void add(SfcFlowClassifier sfcFlowClassifier) {
- // Respective ACL classifier will be written in data store, once the chain is created.
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.sfc.translator.DelegatingDataTreeListener;
-import org.opendaylight.netvirt.sfc.translator.NeutronMdsalHelper;
-import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
-import org.opendaylight.netvirt.sfc.translator.flowclassifier.FlowClassifierTranslator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePathService;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortChains;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChain;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * OpenDaylight Neutron Port Chain yang models data change listener.
- */
-public class NeutronPortChainListener extends DelegatingDataTreeListener<PortChain> {
- private static final Logger LOG = LoggerFactory.getLogger(NeutronPortChainListener.class);
-
- private static final InstanceIdentifier<PortChain> PORT_CHAIN_IID =
- InstanceIdentifier.create(Neutron.class).child(PortChains.class).child(PortChain.class);
- private final SfcMdsalHelper sfcMdsalHelper;
- private final NeutronMdsalHelper neutronMdsalHelper;
- private final RenderedServicePathService rspService;
-
- public NeutronPortChainListener(DataBroker db, RenderedServicePathService rspService) {
- super(db,new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, PORT_CHAIN_IID));
- this.sfcMdsalHelper = new SfcMdsalHelper(db);
- this.neutronMdsalHelper = new NeutronMdsalHelper(db);
- this.rspService = rspService;
- }
-
- /**
- * Method removes PortChain which is identified by InstanceIdentifier.
- *
- * @param deletedPortChain - PortChain for removing
- */
- @Override
- public void remove(PortChain deletedPortChain) {
- sfcMdsalHelper.deleteServiceFunctionPath(PortChainTranslator.getSFPKey(deletedPortChain));
- sfcMdsalHelper.deleteServiceFunctionChain(PortChainTranslator.getSFCKey(deletedPortChain));
- }
-
- /**
- * Method updates the original PortChain to the update PortChain.
- * Both are identified by same InstanceIdentifier.
- *
- * @param origPortChain - original PortChain
- * @param updatePortChain - changed PortChain (contain updates)
- */
- @Override
- public void update(PortChain origPortChain, PortChain updatePortChain) {
- List<Uuid> oldFcList = origPortChain.getFlowClassifiers();
- oldFcList = oldFcList != null ? new ArrayList<>(oldFcList) : new ArrayList<>();
- List<Uuid> newFcList = updatePortChain.getFlowClassifiers();
- if (oldFcList != null && newFcList != null) {
- oldFcList.removeAll(newFcList);
- if (!oldFcList.isEmpty()) {
- LOG.debug("Removing old list {}", oldFcList);
- processFlowClassifiers(origPortChain, oldFcList, null, false);
- }
- }
- processPortChain(updatePortChain);
- }
-
- /**
- * Method adds the PortChain which is identified by InstanceIdentifier
- * to device.
- *
- * @param newPortChain - new PortChain
- */
- @Override
- public void add(final PortChain newPortChain) {
- processPortChain(newPortChain);
- }
-
- private void processPortChain(PortChain newPortChain) {
-
- //List of Port Pair Group attached to the Port Chain
- List<PortPairGroup> portPairGroupList = new ArrayList<>();
- //Port Pair Group and associated Port Pair
- Map<Uuid, List<PortPair>> groupPortPairsList = new HashMap<>();
-
- List<ServiceFunction> portChainServiceFunctionList = new ArrayList<>();
-
- //Read chain related port pair group from neutron data store
- List<Uuid> newPortPairGroups = newPortChain.getPortPairGroups();
- if (newPortPairGroups != null) {
- for (Uuid ppgUuid : newPortPairGroups) {
- PortPairGroup ppg = neutronMdsalHelper.getNeutronPortPairGroup(ppgUuid);
- if (ppg != null) {
- List<PortPair> portPairList = new ArrayList<>();
- portPairGroupList.add(ppg);
- @org.eclipse.jdt.annotation.Nullable List<Uuid> ppgPortPairs = ppg.getPortPairs();
- if (ppgPortPairs != null) {
- for (Uuid ppUuid : ppgPortPairs) {
- PortPair pp = neutronMdsalHelper.getNeutronPortPair(ppUuid);
- if (pp == null) {
- LOG.error("Port pair {} does not exist in the neutron data store", ppUuid);
- return;
- }
- portPairList.add(pp);
- }
- }
- groupPortPairsList.put(ppgUuid, portPairList);
- }
- }
- }
-
- //For each port pair group
- for (PortPairGroup ppg : portPairGroupList) {
-
- List<PortPair> portPairList = groupPortPairsList.get(ppg.getUuid());
-
- //Generate all the SF and write it to SFC data store
- for (PortPair portPair : portPairList) {
- //Build the service function for the given port pair.
- ServiceFunction serviceFunction = PortPairTranslator.buildServiceFunction(portPair, ppg);
- portChainServiceFunctionList.add(serviceFunction);
-
- //Write the Service Function to SFC data store.
- LOG.info("Add Service Function {} for Port Pair {}", serviceFunction, portPair);
- sfcMdsalHelper.addServiceFunction(serviceFunction);
- }
-
- //Build the SFF Builder from port pair group
- ServiceFunctionForwarder serviceFunctionForwarder = PortPairGroupTranslator
- .buildServiceFunctionForwarder(ppg, portPairList);
- // Send SFF create request
- LOG.info("Update Service Function Forwarder with {} for Port Pair Group {}", serviceFunctionForwarder, ppg);
- sfcMdsalHelper.updateServiceFunctionForwarder(serviceFunctionForwarder);
- }
-
- //Build Service Function Chain Builder
- ServiceFunctionChain sfc =
- PortChainTranslator.buildServiceFunctionChain(newPortChain, portChainServiceFunctionList);
-
- //Write SFC to data store
- if (sfc == null) {
- LOG.warn("Service Function Chain building failed for Port Chain {}", newPortChain);
- return;
- }
-
- LOG.info("Add service function chain {}", sfc);
- sfcMdsalHelper.addServiceFunctionChain(sfc);
-
- // Build Service Function Path Builder
- ServiceFunctionPath sfp = PortChainTranslator.buildServiceFunctionPath(sfc);
-
- // Write SFP to data store
- LOG.info("Add service function path {}", sfp);
- sfcMdsalHelper.addServiceFunctionPath(sfp);
-
- // The RSP will automatically be created from the SFP added above.
-
- // Add ACLs from flow classifiers
- List<Uuid> newFlowClassifiers = newPortChain.getFlowClassifiers();
- processFlowClassifiers(newPortChain, newFlowClassifiers != null ? newFlowClassifiers : Collections.emptyList(),
- sfp.getName().getValue(), true);
- }
-
- private void processFlowClassifiers(PortChain pc, @NonNull List<Uuid> flowClassifiers, @Nullable String sfpName,
- boolean added) {
- for (Uuid uuid : flowClassifiers) {
- SfcFlowClassifier fc = neutronMdsalHelper.getNeutronFlowClassifier(uuid);
- if (fc != null) {
- Acl acl = FlowClassifierTranslator.buildAcl(fc, sfpName);
- if (acl != null) {
- if (added) {
- sfcMdsalHelper.addAclFlowClassifier(acl);
- } else {
- sfcMdsalHelper.removeAclFlowClassifier(acl);
- }
- } else {
- LOG.warn("Acl building failed for flow classifier {}. Traffic might not be redirected to RSP", fc);
- }
-
- } else {
- LOG.error("Neutron Flow Classifier {} attached to Port Chain {} is not present in the neutron data "
- + "store", uuid, pc);
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.sfc.translator.DelegatingDataTreeListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortPairGroups;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * OpenDaylight Neutron Port Pair Group yang models data change listener.
- */
-public class NeutronPortPairGroupListener extends DelegatingDataTreeListener<PortPairGroup> {
- private static final InstanceIdentifier<PortPairGroup> PORT_PAIR_GROUP_IID =
- InstanceIdentifier.create(Neutron.class).child(PortPairGroups.class).child(PortPairGroup.class);
-
- public NeutronPortPairGroupListener(DataBroker db) {
- super(db,new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, PORT_PAIR_GROUP_IID));
- }
-
- /**
- * Method removes PortPairGroup which is identified by InstanceIdentifier.
- *
- * @param deletedPortPairGroup - PortPairGroup for removing
- */
- @Override
- public void remove(PortPairGroup deletedPortPairGroup) {
- //NO-OP
- }
-
- /**
- * Method updates the original PortPairGroup to the update PortPairGroup.
- * Both are identified by same InstanceIdentifier.
- *
- * @param origPortPairGroup - original PortPairGroup
- * @param updatePortPairGroup - changed PortPairGroup (contain updates)
- */
- @Override
- public void update(PortPairGroup origPortPairGroup, PortPairGroup updatePortPairGroup) {
- //NO-OP
- }
-
- /**
- * Method adds the PortPairGroup which is identified by InstanceIdentifier
- * to device.
- *
- * @param newPortPairGroup - new PortPairGroup
- */
- @Override
- public void add(PortPairGroup newPortPairGroup) {
- //NO-OP
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.sfc.translator.DelegatingDataTreeListener;
-import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortPairs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * OpenDaylight Neutron Port Pair yang models data change listener.
- */
-public class NeutronPortPairListener extends DelegatingDataTreeListener<PortPair> {
- private static final Logger LOG = LoggerFactory.getLogger(NeutronPortPairListener.class);
-
- private static final InstanceIdentifier<PortPair> PORT_PAIR_IID =
- InstanceIdentifier.create(Neutron.class).child(PortPairs.class).child(PortPair.class);
-
- private final SfcMdsalHelper sfcMdsalHelper;
-
- public NeutronPortPairListener(DataBroker db) {
- super(db,new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, PORT_PAIR_IID));
- sfcMdsalHelper = new SfcMdsalHelper(db);
- }
-
- /**
- * Method removes PortPair which is identified by InstanceIdentifier.
- *
- * @param deletedPortPair - PortPair for removing
- */
- @Override
- public void remove(PortPair deletedPortPair) {
- LOG.info("Received remove port pair event {}", deletedPortPair);
-
- ServiceFunctionKey sfKey = PortPairTranslator.getSFKey(deletedPortPair);
- LOG.info("Removing service function {}", sfKey);
- sfcMdsalHelper.removeServiceFunction(sfKey);
-
- ServiceFunctionForwarder sff;
- ServiceFunctionForwarder updatedSff;
- SffName sffName = new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME);
- sff = sfcMdsalHelper.readServiceFunctionForwarder(new ServiceFunctionForwarderKey(sffName));
- updatedSff = PortPairGroupTranslator.removePortPairFromServiceFunctionForwarder(sff, deletedPortPair);
- LOG.info("Updating service function forwarder as {}", updatedSff);
- sfcMdsalHelper.addServiceFunctionForwarder(updatedSff);
- }
-
- /**
- * Method updates the original PortPair to the update PortPair.
- * Both are identified by same InstanceIdentifier.
- *
- * @param origPortPair - original PortPair
- * @param updatePortPair - changed PortPair (contain updates)
- */
- @Override
- public void update(PortPair origPortPair, PortPair updatePortPair) {
- //NO-OP
- }
-
- /**
- * Method adds the PortPair which is identified by InstanceIdentifier
- * to device.
- *
- * @param newPortPair - new PortPair
- */
- @Override
- public void add(PortPair newPortPair) {
- //NO-OP
- // Port Pair data written in neutron data store will be used
- // When user will create port chain.
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import com.google.common.base.Preconditions;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfcName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfpName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChain;
-
-/**
- * Class will convert OpenStack Port Chain API yang models present in neutron northbound project to OpenDaylight SFC
- * yang models.
- */
-public final class PortChainTranslator {
-
- private static final String SYMMETRIC_PARAM = "symmetric";
- private static final String SFP_NAME_PREFIX = "Path-";
-
- private PortChainTranslator() {
- }
-
- public static ServiceFunctionChain buildServiceFunctionChain(
- PortChain portChain, List<ServiceFunction> sfList) {
- ServiceFunctionChainBuilder sfcBuilder = new ServiceFunctionChainBuilder();
- sfcBuilder.setName(new SfcName(portChain.getName()));
- sfcBuilder.withKey(new ServiceFunctionChainKey(sfcBuilder.getName()));
-
- //By default set it to false. If user specify it in chain parameters, it will be overridden
- sfcBuilder.setSymmetric(false);
-
- //Set service functions
- List<SfcServiceFunction> sfcSfList = new ArrayList<>();
- for (ServiceFunction sf : sfList) {
- SfcServiceFunctionBuilder sfcSfBuilder = new SfcServiceFunctionBuilder();
- sfcSfBuilder.setName(sf.getName().getValue());
- sfcSfBuilder.setType(sf.getType());
- sfcSfBuilder.withKey(new SfcServiceFunctionKey(sfcSfBuilder.getName()));
-
- //NOTE: no explicit order is set.
- sfcSfList.add(sfcSfBuilder.build());
- }
- List<ChainParameters> cpList = portChain.getChainParameters();
- if (cpList != null && !cpList.isEmpty()) {
- for (ChainParameters cp : cpList) {
- if (SYMMETRIC_PARAM.equals(cp.getChainParameter())) {
- //Override the symmetric default value.
- sfcBuilder.setSymmetric(Boolean.valueOf(cp.getChainParameterValue()));
- break;
- }
- }
- }
- sfcBuilder.setSfcServiceFunction(sfcSfList);
- return sfcBuilder.build();
- }
-
- public static ServiceFunctionPath buildServiceFunctionPath(ServiceFunctionChain sfc) {
- Preconditions.checkNotNull(sfc, "Service Function Chain must not be null");
- ServiceFunctionPathBuilder sfpBuilder = new ServiceFunctionPathBuilder();
-
- //Set the name
- sfpBuilder.setName(new SfpName(SFP_NAME_PREFIX + sfc.getName().getValue()));
-
- sfpBuilder.setSymmetric(sfc.isSymmetric());
- //Set related SFC name
- sfpBuilder.setServiceChainName(sfc.getName());
- return sfpBuilder.build();
- }
-
- public static ServiceFunctionChainKey getSFCKey(PortChain portChain) {
- return new ServiceFunctionChainKey(new SfcName(portChain.getName()));
- }
-
- public static ServiceFunctionPathKey getSFPKey(PortChain portChain) {
- return new ServiceFunctionPathKey(new SfpName(SFP_NAME_PREFIX + portChain.getName()));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import com.google.common.base.Preconditions;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterface;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterfaceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class will convert OpenStack Port Pair API yang models present in
- * neutron northbound project to OpenDaylight SFC yang models.
- */
-public final class PortPairGroupTranslator {
- private static final Logger LOG = LoggerFactory.getLogger(PortPairGroupTranslator.class);
-
- private static final String DPL_EGRESS_SUFFIX = "-egress";
- private static final String DPL_INGRESS_SUFFIX = "-ingress";
-
- private PortPairGroupTranslator() {
-
- }
-
- public static ServiceFunctionForwarder buildServiceFunctionForwarder(
- PortPairGroup portPairGroup,
- List<PortPair> portPairs) {
- Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
- Preconditions.checkNotNull(portPairs, "Port pairs must not be null");
- Preconditions.checkElementIndex(0, portPairs.size(), "There must be at least one port pair");
-
- //Currently we only support one SF per type. Mean, one port-pair per port-pair-group.
- final PortPair portPair = portPairs.get(0);
-
- ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
- sffBuilder.setName(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
-
- DataPlaneLocatorBuilder forwardDplBuilder = new DataPlaneLocatorBuilder();
- forwardDplBuilder.setTransport(Mac.class);
- String forwardPort = portPair.getIngress().getValue();
- LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
- forwardDplBuilder.setLocatorType(forwardInterface);
- SffDataPlaneLocatorBuilder sffForwardDplBuilder = new SffDataPlaneLocatorBuilder();
- sffForwardDplBuilder.setDataPlaneLocator(forwardDplBuilder.build());
- String forwardDplName = portPair.getName() + DPL_INGRESS_SUFFIX;
- sffForwardDplBuilder.setName(new SffDataPlaneLocatorName(forwardDplName));
-
- DataPlaneLocatorBuilder reverseDplBuilder = new DataPlaneLocatorBuilder();
- reverseDplBuilder.setTransport(Mac.class);
- String reversePort = portPair.getEgress().getValue();
- LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
- reverseDplBuilder.setLocatorType(reverseInterface);
- SffDataPlaneLocatorBuilder sffReverseDplBuilder = new SffDataPlaneLocatorBuilder();
- sffReverseDplBuilder.setDataPlaneLocator(reverseDplBuilder.build());
- String reverseDplName = portPair.getName() + DPL_EGRESS_SUFFIX;
- sffReverseDplBuilder.setName(new SffDataPlaneLocatorName(reverseDplName));
-
- List<SffDataPlaneLocator> sffDataPlaneLocator = new ArrayList<>();
- sffDataPlaneLocator.add(sffForwardDplBuilder.build());
- sffDataPlaneLocator.add(sffReverseDplBuilder.build());
- sffBuilder.setSffDataPlaneLocator(sffDataPlaneLocator);
-
- SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
- sffSfDataPlaneLocatorBuilder.setSffForwardDplName(new SffDataPlaneLocatorName(forwardDplName));
- sffSfDataPlaneLocatorBuilder.setSfForwardDplName(new SfDataPlaneLocatorName(forwardDplName));
- sffSfDataPlaneLocatorBuilder.setSffReverseDplName(new SffDataPlaneLocatorName(reverseDplName));
- sffSfDataPlaneLocatorBuilder.setSfReverseDplName(new SfDataPlaneLocatorName(reverseDplName));
- ServiceFunctionDictionaryBuilder sfdBuilder = new ServiceFunctionDictionaryBuilder();
- sfdBuilder.setName(new SfName(portPair.getName()));
- sfdBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
-
- List<ServiceFunctionDictionary> sfdList = new ArrayList<>();
- sfdList.add(sfdBuilder.build());
- sffBuilder.setServiceFunctionDictionary(sfdList);
-
- return sffBuilder.build();
- }
-
- public static ServiceFunctionForwarder removePortPairFromServiceFunctionForwarder(
- ServiceFunctionForwarder serviceFunctionForwarder,
- PortPair deletedPortPair) {
- Preconditions.checkNotNull(deletedPortPair, "Port pair must not be null");
-
- String portPairName = deletedPortPair.getName();
- ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder(serviceFunctionForwarder);
-
- List<ServiceFunctionDictionary> serviceFunctionDictionaryList = sffBuilder.getServiceFunctionDictionary();
- if (serviceFunctionDictionaryList == null) {
- LOG.debug("SF dictionary is empty");
- return serviceFunctionForwarder;
- }
-
- ServiceFunctionDictionary serviceFunctionDictionary = serviceFunctionDictionaryList.stream()
- .filter(sfDictionary -> sfDictionary.getName().getValue().equals(portPairName))
- .findFirst()
- .orElse(null);
-
- if (serviceFunctionDictionary == null) {
- LOG.debug("SFF dictionary entry for port pair {} not found", portPairName);
- return serviceFunctionForwarder;
- }
-
- SffSfDataPlaneLocator sffSfDataPlaneLocator = serviceFunctionDictionary.getSffSfDataPlaneLocator();
- if (sffSfDataPlaneLocator != null) {
- List<SffDataPlaneLocatorName> locators = Arrays.asList(
- sffSfDataPlaneLocator.getSffDplName(),
- sffSfDataPlaneLocator.getSffForwardDplName(),
- sffSfDataPlaneLocator.getSffReverseDplName());
- List<SffDataPlaneLocator> sffDplList = sffBuilder.getSffDataPlaneLocator();
- if (sffDplList != null) {
- sffDplList.stream()
- .filter(sffDataPlaneLocator -> locators.contains(sffDataPlaneLocator.getName()))
- .map(sffDplList::remove);
- }
- }
- serviceFunctionDictionaryList.remove(serviceFunctionDictionary);
-
- return sffBuilder.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.sfc.translator.portchain;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableBiMap;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SftTypeName;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.TenantId;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocator;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.base.SfDataPlaneLocatorBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.SlTransportType;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.functions.service.function.sf.data.plane.locator.locator.type.LogicalInterface;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.functions.service.function.sf.data.plane.locator.locator.type.LogicalInterfaceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.pair.attributes.ServiceFunctionParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair;
-
-/**
- * Class will convert OpenStack Port Pair API yang models present in
- * neutron northbound project to OpenDaylight SFC Service Function yang models.
- */
-public final class PortPairTranslator {
- private static final String SF_TYPE_PARAM = "type";
- private static final String DPL_TRANSPORT_PARAM = "dpl-transport";
- private static final String DPL_EGRESS_SUFFIX = "-egress";
- private static final String DPL_INGRESS_SUFFIX = "-ingress";
-
- public static final ImmutableBiMap<String, Class<? extends SlTransportType>> DPL_TRANSPORT_TYPE
- = new ImmutableBiMap.Builder<String, Class<? extends SlTransportType>>()
- .put("mac", Mac.class).build();
-
- private PortPairTranslator() {
-
- }
-
- @NonNull
- public static ServiceFunction buildServiceFunction(
- PortPair portPair,
- PortPairGroup portPairGroup) {
- Preconditions.checkNotNull(portPair, "Port pair must not be null");
- Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
-
- ServiceFunctionBuilder serviceFunctionBuilder = new ServiceFunctionBuilder();
-
- //Set SF name and tenant-id
- serviceFunctionBuilder.setName(new SfName(portPair.getName()));
- serviceFunctionBuilder.setTenantId(new TenantId(portPair.getTenantId().getValue()));
-
- //Set SF Type. Setting it to PortPairGroup Type, this will be overridden if user pass
- //it through service_function_params
- serviceFunctionBuilder.setType(SftTypeName.getDefaultInstance(portPairGroup.getName()));
-
- //If user pass specific param using service_function_parameters, set/override it accordingly
- Class transportTypeClass = null;
- List<ServiceFunctionParameters> sfParams = portPair.getServiceFunctionParameters();
- if (sfParams != null) {
- for (ServiceFunctionParameters sfParam : sfParams) {
- //There is by default type set to port pair group name, override it if user pass it specific type
- if (sfParam.getServiceFunctionParameter().equals(SF_TYPE_PARAM)) {
- serviceFunctionBuilder.setType(new SftTypeName(sfParam.getServiceFunctionParameterValue()));
- }
- if (sfParam.getServiceFunctionParameter().equals(DPL_TRANSPORT_PARAM)) {
- transportTypeClass = DPL_TRANSPORT_TYPE.get(sfParam.getServiceFunctionParameterValue());
- }
- }
- }
-
- //Build forward DPL
- SfDataPlaneLocatorBuilder sfForwardDplBuilder = new SfDataPlaneLocatorBuilder();
- sfForwardDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_INGRESS_SUFFIX));
- sfForwardDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
- sfForwardDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
- String forwardPort = portPair.getIngress().getValue();
- LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
- sfForwardDplBuilder.setLocatorType(forwardInterface);
-
- //Build reverse DPL
- SfDataPlaneLocatorBuilder sfReverseDplBuilder = new SfDataPlaneLocatorBuilder();
- sfReverseDplBuilder.setName(new SfDataPlaneLocatorName(portPair.getName() + DPL_EGRESS_SUFFIX));
- sfReverseDplBuilder.setTransport(transportTypeClass == null ? Mac.class : transportTypeClass);
- sfReverseDplBuilder.setServiceFunctionForwarder(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
- String reversePort = portPair.getEgress().getValue();
- LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
- sfReverseDplBuilder.setLocatorType(reverseInterface);
-
- //Set all data plane locator
- List<SfDataPlaneLocator> sfDataPlaneLocatorList = new ArrayList<>();
- sfDataPlaneLocatorList.add(sfForwardDplBuilder.build());
- sfDataPlaneLocatorList.add(sfReverseDplBuilder.build());
- serviceFunctionBuilder.setSfDataPlaneLocator(sfDataPlaneLocatorList);
-
- return serviceFunctionBuilder.build();
- }
-
- public static ServiceFunctionKey getSFKey(PortPair portPair) {
- return new ServiceFunctionKey(new SfName(portPair.getName()));
- }
-
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="dataBroker"
- interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" />
- <odl:rpc-service id="renderedServicePathService"
- interface="org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePathService"/>
-
-</blueprint>