Committed by
Gerrit Code Review
Removing all existing Netconf flow rule implementation: not compatible with curr…
…ent version and tailored on specific software. Doing so removes all ties with odl Yangtools in ONOS core. Change-Id: I4315bdf20dc388d42ea6f0f6276689da9a75c741
Showing
7 changed files
with
1 additions
and
1054 deletions
| ... | @@ -37,12 +37,7 @@ | ... | @@ -37,12 +37,7 @@ |
| 37 | <artifactId>onos-netconf-provider-device</artifactId> | 37 | <artifactId>onos-netconf-provider-device</artifactId> |
| 38 | <version>${project.version}</version> | 38 | <version>${project.version}</version> |
| 39 | </dependency> | 39 | </dependency> |
| 40 | - <dependency> | 40 | + <!-- Add other dependencies here as more bundles are added to the app --> |
| 41 | - <groupId>org.onosproject</groupId> | ||
| 42 | - <artifactId>onos-netconf-provider-flow</artifactId> | ||
| 43 | - <version>${project.version}</version> | ||
| 44 | - </dependency> | ||
| 45 | - <!-- TODO: add other dependencies here as more bundles are added to the app --> | ||
| 46 | </dependencies> | 41 | </dependencies> |
| 47 | 42 | ||
| 48 | </project> | 43 | </project> | ... | ... |
providers/netconf/flow/pom.xml
deleted
100644 → 0
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!-- | ||
| 3 | - ~ Copyright 2014 Open Networking Laboratory | ||
| 4 | - ~ | ||
| 5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | - ~ you may not use this file except in compliance with the License. | ||
| 7 | - ~ You may obtain a copy of the License at | ||
| 8 | - ~ | ||
| 9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | - ~ | ||
| 11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
| 12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | - ~ See the License for the specific language governing permissions and | ||
| 15 | - ~ limitations under the License. | ||
| 16 | - --> | ||
| 17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 20 | - <modelVersion>4.0.0</modelVersion> | ||
| 21 | - | ||
| 22 | - <parent> | ||
| 23 | - <groupId>org.onosproject</groupId> | ||
| 24 | - <artifactId>onos-netconf-providers</artifactId> | ||
| 25 | - <version>1.4.0-SNAPSHOT</version> | ||
| 26 | - <relativePath>../pom.xml</relativePath> | ||
| 27 | - </parent> | ||
| 28 | - | ||
| 29 | - <artifactId>onos-netconf-provider-flow</artifactId> | ||
| 30 | - <packaging>bundle</packaging> | ||
| 31 | - | ||
| 32 | - <dependencies> | ||
| 33 | - <dependency> | ||
| 34 | - <groupId>org.osgi</groupId> | ||
| 35 | - <artifactId>org.osgi.compendium</artifactId> | ||
| 36 | - </dependency> | ||
| 37 | - <dependency> | ||
| 38 | - <groupId>ch.ethz.ganymed</groupId> | ||
| 39 | - <artifactId>ganymed-ssh2</artifactId> | ||
| 40 | - <version>262</version> | ||
| 41 | - </dependency> | ||
| 42 | - <dependency> | ||
| 43 | - <!-- TODO: change this appropriately when the official TailF JNC is available --> | ||
| 44 | - <groupId>org.onosproject</groupId> | ||
| 45 | - <artifactId>jnc</artifactId> | ||
| 46 | - <version>1.0</version> | ||
| 47 | - </dependency> | ||
| 48 | - <dependency> | ||
| 49 | - <groupId>org.jdom</groupId> | ||
| 50 | - <artifactId>jdom2</artifactId> | ||
| 51 | - <version>2.0.5</version> | ||
| 52 | - </dependency> | ||
| 53 | - <dependency> | ||
| 54 | - <groupId>jaxen</groupId> | ||
| 55 | - <artifactId>jaxen</artifactId> | ||
| 56 | - <version>1.1.4</version> | ||
| 57 | - <optional>true</optional> | ||
| 58 | - </dependency> | ||
| 59 | - <dependency> | ||
| 60 | - <groupId>org.osgi</groupId> | ||
| 61 | - <artifactId>org.osgi.core</artifactId> | ||
| 62 | - </dependency> | ||
| 63 | - <dependency> | ||
| 64 | - <groupId>org.onosproject</groupId> | ||
| 65 | - <artifactId>onlab-junit</artifactId> | ||
| 66 | - <scope>test</scope> | ||
| 67 | - </dependency> | ||
| 68 | - <dependency> | ||
| 69 | - <groupId>org.easymock</groupId> | ||
| 70 | - <artifactId>easymock</artifactId> | ||
| 71 | - <scope>test</scope> | ||
| 72 | - </dependency> | ||
| 73 | - <dependency> | ||
| 74 | - <groupId>org.onosproject</groupId> | ||
| 75 | - <artifactId>onos-yang-tool</artifactId> | ||
| 76 | - <version>1.3</version> | ||
| 77 | - </dependency> | ||
| 78 | - </dependencies> | ||
| 79 | - | ||
| 80 | - <build> | ||
| 81 | - <plugins> | ||
| 82 | - <plugin> | ||
| 83 | - <groupId>org.apache.maven.plugins</groupId> | ||
| 84 | - <artifactId>maven-shade-plugin</artifactId> | ||
| 85 | - <version>2.3</version> | ||
| 86 | - <configuration> | ||
| 87 | - <filters> | ||
| 88 | - <filter> | ||
| 89 | - <artifact>com.tailf:JNC</artifact> | ||
| 90 | - <includes> | ||
| 91 | - <include>com/tailf/jnc/**</include> | ||
| 92 | - </includes> | ||
| 93 | - </filter> | ||
| 94 | - <filter> | ||
| 95 | - <artifact>ch.ethz.ganymed:ganymed-ssh2</artifact> | ||
| 96 | - <includes> | ||
| 97 | - <include>ch/ethz/ssh2/**</include> | ||
| 98 | - </includes> | ||
| 99 | - </filter> | ||
| 100 | - <filter> | ||
| 101 | - <artifact>org.jdom:jdom2</artifact> | ||
| 102 | - <includes> | ||
| 103 | - <include>org/jdom2/**</include> | ||
| 104 | - </includes> | ||
| 105 | - </filter> | ||
| 106 | - <filter> | ||
| 107 | - <artifact>org.onosproject:onos-yang-tool</artifact> | ||
| 108 | - <includes> | ||
| 109 | - <include>org/opendaylight/yang/gen/**</include> | ||
| 110 | - </includes> | ||
| 111 | - </filter> | ||
| 112 | - </filters> | ||
| 113 | - </configuration> | ||
| 114 | - <executions> | ||
| 115 | - <execution> | ||
| 116 | - <phase>package</phase> | ||
| 117 | - <goals> | ||
| 118 | - <goal>shade</goal> | ||
| 119 | - </goals> | ||
| 120 | - </execution> | ||
| 121 | - </executions> | ||
| 122 | - </plugin> | ||
| 123 | - <plugin> | ||
| 124 | - <groupId>org.apache.felix</groupId> | ||
| 125 | - <artifactId>maven-scr-plugin</artifactId> | ||
| 126 | - </plugin> | ||
| 127 | - <plugin> | ||
| 128 | - <groupId>org.apache.felix</groupId> | ||
| 129 | - <artifactId>maven-bundle-plugin</artifactId> | ||
| 130 | - <configuration> | ||
| 131 | - <instructions> | ||
| 132 | - <Export-Package> | ||
| 133 | - com.tailf.jnc, | ||
| 134 | - ch.ethz.ssh2, | ||
| 135 | - ch.ethz.ssh2.auth, | ||
| 136 | - ch.ethz.ssh2.channel, | ||
| 137 | - ch.ethz.ssh2.crypto, | ||
| 138 | - ch.ethz.ssh2.crypto.cipher, | ||
| 139 | - ch.ethz.ssh2.crypto.dh, | ||
| 140 | - ch.ethz.ssh2.crypto.digest, | ||
| 141 | - ch.ethz.ssh2.log, | ||
| 142 | - ch.ethz.ssh2.packets, | ||
| 143 | - ch.ethz.ssh2.server, | ||
| 144 | - ch.ethz.ssh2.sftp, | ||
| 145 | - ch.ethz.ssh2.signature, | ||
| 146 | - ch.ethz.ssh2.transport, | ||
| 147 | - ch.ethz.ssh2.util, | ||
| 148 | - org.jdom2, | ||
| 149 | - org.jdom2.input, | ||
| 150 | - org.jdom2.output, | ||
| 151 | - org.jdom2.adapters, | ||
| 152 | - org.jdom2.filter, | ||
| 153 | - org.jdom2.internal, | ||
| 154 | - org.jdom2.located, | ||
| 155 | - org.jdom2.transform, | ||
| 156 | - org.jdom2.util, | ||
| 157 | - org.jdom2.xpath, | ||
| 158 | - org.jdom2.input.sax, | ||
| 159 | - org.jdom2.input.stax, | ||
| 160 | - org.jdom2.output.support, | ||
| 161 | - org.jdom2.xpath.jaxen, | ||
| 162 | - org.jdom2.xpath.util, | ||
| 163 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520, | ||
| 164 | - org.opendaylight.yangtools.yang.data.impl.schema.tree, | ||
| 165 | - org.opendaylight.yangtools.yang.data.impl.codec, | ||
| 166 | - org.opendaylight.yangtools.yang.model.parser.api, | ||
| 167 | - org.opendaylight.yangtools.yang.data.impl.schema.nodes, | ||
| 168 | - org.opendaylight.yangtools.yang.binding.util, | ||
| 169 | - org.opendaylight.yangtools.yang.data.impl, | ||
| 170 | - org.opendaylight.yangtools.sal.binding.generator.impl, | ||
| 171 | - org.opendaylight.yangtools.yang.parser.impl.util, | ||
| 172 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625, | ||
| 173 | - org.opendaylight.yangtools.yang.data.api, | ||
| 174 | - org.opendaylight.yangtools.objcache.spi, | ||
| 175 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.base.parser, | ||
| 176 | - org.opendaylight.yangtools.maven.sal.api.gen.plugin, | ||
| 177 | - org.opendaylight.yangtools.yang.data.impl.schema.builder.impl, | ||
| 178 | - org.opendaylight.yangtools.yang.data.api.schema.tree, | ||
| 179 | - org.opendaylight.yangtools.binding.generator.util, | ||
| 180 | - org.opendaylight.yangtools.sal.binding.generator.spi, | ||
| 181 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715, | ||
| 182 | - org.opendaylight.yangtools.yang2sources.spi, | ||
| 183 | - org.opendaylight.yangtools.yang.model.repo.api, | ||
| 184 | - org.opendaylight.yangtools.util, | ||
| 185 | - org.opendaylight.yangtools.yang.parser.util, | ||
| 186 | - org.opendaylight.yangtools.yang.data.api.schema.stream, | ||
| 187 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer, | ||
| 188 | - org.opendaylight.yangtools.concepts, | ||
| 189 | - org.opendaylight.yangtools.yang.binding, | ||
| 190 | - org.opendaylight.yangtools.yang.model.util.repo, | ||
| 191 | - org.opendaylight.yangtools.yang.wadl.generator.maven, | ||
| 192 | - org.opendaylight.yangtools.yang.data.api.schema, | ||
| 193 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type, | ||
| 194 | - org.opendaylight.yangtools.concepts.util, | ||
| 195 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries, | ||
| 196 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.ace.ip.version, | ||
| 197 | - org.opendaylight.yangtools.sal.binding.model.api, | ||
| 198 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip, | ||
| 199 | - org.opendaylight.yangtools.yang.data.impl.schema.builder.api, | ||
| 200 | - org.opendaylight.yangtools.util.concurrent, | ||
| 201 | - org.opendaylight.yangtools.yang.parser.builder.impl, | ||
| 202 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.base, | ||
| 203 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.actions.packet.handling, | ||
| 204 | - org.opendaylight.yangtools.sal.binding.model.api.type.builder, | ||
| 205 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields, | ||
| 206 | - org.opendaylight.yangtools.yang2sources.plugin, | ||
| 207 | - org.opendaylight.yangtools.yang.data.impl.codec.xml, | ||
| 208 | - org.opendaylight.yangtools.antlrv4.code.gen, | ||
| 209 | - org.opendaylight.yangtools.yang.parser.builder.util, | ||
| 210 | - org.opendaylight.yangtools.yang.data.impl.schema.transform, | ||
| 211 | - org.opendaylight.yangtools.yang.model.api.type, | ||
| 212 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.serializer, | ||
| 213 | - org.opendaylight.yangtools.yang.data.api.schema.tree.spi, | ||
| 214 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser, | ||
| 215 | - org.opendaylight.yangtools.sal.binding.yang.types, | ||
| 216 | - org.opendaylight.yangtools.yang.data.impl.schema.transform.dom, | ||
| 217 | - org.opendaylight.yangtools.yang.data.impl.util, | ||
| 218 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.timerange, | ||
| 219 | - org.opendaylight.yangtools.sal.binding.generator.api, | ||
| 220 | - org.opendaylight.yangtools.sal.java.api.generator, | ||
| 221 | - org.opendaylight.yangtools.yang.binding.annotations, | ||
| 222 | - org.opendaylight.yangtools.sal.binding.generator.util, | ||
| 223 | - org.opendaylight.yangtools.yang.model.repo.util, | ||
| 224 | - org.opendaylight.yangtools.yang.model.api, | ||
| 225 | - org.opendaylight.yangtools.yang.common, | ||
| 226 | - org.opendaylight.yangtools.yang.wadl.generator, | ||
| 227 | - org.opendaylight.yangtools.yang.parser.builder.api, | ||
| 228 | - org.opendaylight.yangtools.yang.model.util, | ||
| 229 | - org.opendaylight.yangtools.yang.parser.impl, | ||
| 230 | - org.opendaylight.yangtools.yang.data.impl.schema, | ||
| 231 | - org.opendaylight.yangtools.yang.data.api.codec, | ||
| 232 | - org.opendaylight.yangtools.yang.unified.doc.generator, | ||
| 233 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list, | ||
| 234 | - org.opendaylight.yangtools.objcache, | ||
| 235 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.actions, | ||
| 236 | - org.opendaylight.yangtools.yang.data.util, | ||
| 237 | - org.opendaylight.yangtools.yang.unified.doc.generator.maven, | ||
| 238 | - org.opendaylight.yangtools.binding.generator.util.generated.type.builder, | ||
| 239 | - org.opendaylight.yangtools.yang.model.repo.spi, | ||
| 240 | - org.opendaylight.yangtools.yang.parser.repo, | ||
| 241 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715, | ||
| 242 | - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches, | ||
| 243 | - org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid, | ||
| 244 | - com.romix.scala, | ||
| 245 | - com.romix.scala.collection, | ||
| 246 | - com.romix.scala.collection.concurrent, | ||
| 247 | - org.opendaylight.yangtools.objcache.impl | ||
| 248 | - </Export-Package> | ||
| 249 | - </instructions> | ||
| 250 | - </configuration> | ||
| 251 | - </plugin> | ||
| 252 | - <plugin> | ||
| 253 | - <groupId>org.onosproject</groupId> | ||
| 254 | - <artifactId>onos-maven-plugin</artifactId> | ||
| 255 | - </plugin> | ||
| 256 | - </plugins> | ||
| 257 | - </build> | ||
| 258 | - | ||
| 259 | -</project> |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.provider.netconf.flow.impl; | ||
| 17 | - | ||
| 18 | -import static com.google.common.base.Strings.isNullOrEmpty; | ||
| 19 | -import static org.onlab.util.Tools.get; | ||
| 20 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 21 | - | ||
| 22 | -import java.net.URI; | ||
| 23 | -import java.net.URISyntaxException; | ||
| 24 | -import java.util.ArrayList; | ||
| 25 | -import java.util.Collections; | ||
| 26 | -import java.util.Dictionary; | ||
| 27 | -import java.util.Enumeration; | ||
| 28 | -import java.util.HashMap; | ||
| 29 | -import java.util.List; | ||
| 30 | -import java.util.Map; | ||
| 31 | -import java.util.Set; | ||
| 32 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 33 | -import java.util.concurrent.ConcurrentMap; | ||
| 34 | -import java.util.concurrent.TimeUnit; | ||
| 35 | - | ||
| 36 | -import org.apache.felix.scr.annotations.Activate; | ||
| 37 | -import org.apache.felix.scr.annotations.Component; | ||
| 38 | -import org.apache.felix.scr.annotations.Deactivate; | ||
| 39 | -import org.apache.felix.scr.annotations.Modified; | ||
| 40 | -import org.apache.felix.scr.annotations.Reference; | ||
| 41 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 42 | -import org.jboss.netty.util.HashedWheelTimer; | ||
| 43 | -import org.jboss.netty.util.Timeout; | ||
| 44 | -import org.jboss.netty.util.TimerTask; | ||
| 45 | -import org.onlab.util.Timer; | ||
| 46 | -import org.onosproject.core.ApplicationId; | ||
| 47 | -import org.onosproject.net.DeviceId; | ||
| 48 | -import org.onosproject.net.flow.FlowEntry; | ||
| 49 | -import org.onosproject.net.flow.FlowRule; | ||
| 50 | -import org.onosproject.net.flow.FlowRuleBatchOperation; | ||
| 51 | -import org.onosproject.net.flow.FlowRuleProvider; | ||
| 52 | -import org.onosproject.net.flow.FlowRuleProviderRegistry; | ||
| 53 | -import org.onosproject.net.flow.FlowRuleProviderService; | ||
| 54 | -import org.onosproject.net.provider.AbstractProvider; | ||
| 55 | -import org.onosproject.net.provider.ProviderId; | ||
| 56 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessList; | ||
| 57 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessListBuilder; | ||
| 58 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.AccessListEntries; | ||
| 59 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.AccessListEntriesBuilder; | ||
| 60 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.ActionsBuilder; | ||
| 61 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.Matches; | ||
| 62 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.MatchesBuilder; | ||
| 63 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.actions.packet.handling.DenyBuilder; | ||
| 64 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.actions.packet.handling.PermitBuilder; | ||
| 65 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.AceIp; | ||
| 66 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.AceIpBuilder; | ||
| 67 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.ace.ip.version.AceIpv4; | ||
| 68 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder; | ||
| 69 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; | ||
| 70 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; | ||
| 71 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.DestinationPortRange; | ||
| 72 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.DestinationPortRangeBuilder; | ||
| 73 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.SourcePortRange; | ||
| 74 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.SourcePortRangeBuilder; | ||
| 75 | -import org.osgi.service.component.ComponentContext; | ||
| 76 | -import org.slf4j.Logger; | ||
| 77 | - | ||
| 78 | -/** | ||
| 79 | - * Netconf provider to accept any flow and report them. | ||
| 80 | - */ | ||
| 81 | -@Component(immediate = true) | ||
| 82 | -public class NetconfFlowRuleProvider extends AbstractProvider | ||
| 83 | - implements FlowRuleProvider { | ||
| 84 | - private final Logger log = getLogger(getClass()); | ||
| 85 | - | ||
| 86 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 87 | - protected FlowRuleProviderRegistry providerRegistry; | ||
| 88 | - | ||
| 89 | - private ConcurrentMap<DeviceId, Set<FlowEntry>> flowTable = new ConcurrentHashMap<>(); | ||
| 90 | - | ||
| 91 | - private FlowRuleProviderService providerService; | ||
| 92 | - | ||
| 93 | - private XmlBuilder xmlBuilder; | ||
| 94 | - | ||
| 95 | - private AceIp aceIp; | ||
| 96 | - private SourcePortRange srcPortRange; | ||
| 97 | - private DestinationPortRange destPortRange; | ||
| 98 | - private Matches matches; | ||
| 99 | - private HashedWheelTimer timer = Timer.getTimer(); | ||
| 100 | - private Timeout timeout; | ||
| 101 | - private static final String ACL_NAME_KEY = "acl-name"; | ||
| 102 | - private static final String ACL_LIST_ENTRIES_RULE_NAME_KEY = "access-list-entries.rule-name"; | ||
| 103 | - private static final String ACL_LIST_SP_LOWER_KEY = "source-port-range.lower-port"; | ||
| 104 | - private static final String ACL_LIST_SP_UPPER_KEY = "source-port-range.upper-port"; | ||
| 105 | - private static final String ACL_LIST_DP_LOWER_KEY = "destination-port-range.lower-port"; | ||
| 106 | - private static final String ACL_LIST_DP_UPPER_KEY = "destination-port-range.upper-port"; | ||
| 107 | - private static final String ACL_LIST_DEST_IPV4_KEY = "matches.destination-ipv4-address"; | ||
| 108 | - private static final String ACL_LIST_SRC_IPV4_KEY = "matches.source-ipv4-address"; | ||
| 109 | - private static final String ACL_LIST_ACTIONS_KEY = "actions"; | ||
| 110 | - | ||
| 111 | - public NetconfFlowRuleProvider() { | ||
| 112 | - super(new ProviderId("netconf", "org.onosproject.provider.netconf")); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - @Activate | ||
| 116 | - public void activate(ComponentContext context) { | ||
| 117 | - providerService = providerRegistry.register(this); | ||
| 118 | - timeout = timer.newTimeout(new StatisticTask(), 5, TimeUnit.SECONDS); | ||
| 119 | - applyRule(); | ||
| 120 | - modified(context); | ||
| 121 | - log.info("Started"); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - @Deactivate | ||
| 125 | - public void deactivate() { | ||
| 126 | - providerRegistry.unregister(this); | ||
| 127 | - providerService = null; | ||
| 128 | - timeout.cancel(); | ||
| 129 | - log.info("Stopped"); | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - @Modified | ||
| 133 | - public void modified(ComponentContext context) { | ||
| 134 | - if (xmlBuilder == null) { | ||
| 135 | - xmlBuilder = new XmlBuilder(); | ||
| 136 | - } | ||
| 137 | - if (context == null) { | ||
| 138 | - log.info("No configuration file"); | ||
| 139 | - return; | ||
| 140 | - } | ||
| 141 | - Dictionary<?, ?> properties = context.getProperties(); | ||
| 142 | - String deviceEntry = get(properties, "devConfigs"); | ||
| 143 | - log.info("Settings: devConfigs={}", deviceEntry); | ||
| 144 | - Enumeration<?> elements = properties.keys(); | ||
| 145 | - Object nextElement = elements.nextElement(); | ||
| 146 | - while (elements.hasMoreElements()) { | ||
| 147 | - if (nextElement instanceof String) { | ||
| 148 | - log.info("key::" + nextElement + ", value::" | ||
| 149 | - + get(properties, (String) nextElement)); | ||
| 150 | - } | ||
| 151 | - nextElement = elements.nextElement(); | ||
| 152 | - } | ||
| 153 | - if (!isNullOrEmpty(deviceEntry)) { | ||
| 154 | - Map<String, String> deviceMap = processDeviceEntry(deviceEntry); | ||
| 155 | - AccessList accessList = buildAccessList(properties); | ||
| 156 | - String xmlMsg = xmlBuilder.buildAclRequestXml(accessList); | ||
| 157 | - log.info("The resultant xml from the builder\n" + xmlMsg); | ||
| 158 | - NetconfOperation netconfOperation = new NetconfOperation(); | ||
| 159 | - netconfOperation.sendXmlMessage(xmlMsg, deviceMap.get("username"), | ||
| 160 | - deviceMap.get("password"), | ||
| 161 | - deviceMap.get("hostIp"), Integer | ||
| 162 | - .parseInt(deviceMap | ||
| 163 | - .get("hostPort"))); | ||
| 164 | - } | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - /** | ||
| 168 | - * @param properties | ||
| 169 | - * @return accessList | ||
| 170 | - */ | ||
| 171 | - private AccessList buildAccessList(Dictionary<?, ?> properties) { | ||
| 172 | - /** | ||
| 173 | - * Populating Access List. | ||
| 174 | - */ | ||
| 175 | - AccessListBuilder abuilder = new AccessListBuilder(); | ||
| 176 | - String aclName = get(properties, ACL_NAME_KEY); | ||
| 177 | - if (aclName != null) { | ||
| 178 | - abuilder.setAclName(aclName); | ||
| 179 | - } | ||
| 180 | - AccessList accessList = abuilder.build(); | ||
| 181 | - abuilder.setAccessListEntries(getAccessListEntries(properties, matches)); | ||
| 182 | - srcPortRange = getSourcePortRange(properties); | ||
| 183 | - destPortRange = getDestinationPortRange(properties); | ||
| 184 | - aceIp = getAceIp(properties, srcPortRange, destPortRange); | ||
| 185 | - matches = getMatches(properties); | ||
| 186 | - return accessList; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - /** | ||
| 190 | - * @param properties | ||
| 191 | - * @return matches | ||
| 192 | - */ | ||
| 193 | - private Matches getMatches(Dictionary<?, ?> properties) { | ||
| 194 | - /** | ||
| 195 | - * Building Matches for given ACL model. | ||
| 196 | - */ | ||
| 197 | - MatchesBuilder matchesBuilder = new MatchesBuilder(); | ||
| 198 | - if (aceIp != null) { | ||
| 199 | - matchesBuilder.setAceType(aceIp); | ||
| 200 | - } | ||
| 201 | - matches = matchesBuilder.build(); | ||
| 202 | - return matches; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - /** | ||
| 206 | - * @param properties | ||
| 207 | - * @return srcPortRange | ||
| 208 | - */ | ||
| 209 | - private SourcePortRange getSourcePortRange(Dictionary<?, ?> properties) { | ||
| 210 | - /** | ||
| 211 | - * Building Source Port Range for given ACL model. | ||
| 212 | - */ | ||
| 213 | - String spRangeLowerStr = get(properties, ACL_LIST_SP_LOWER_KEY); | ||
| 214 | - String spRangeUpperStr = get(properties, ACL_LIST_SP_UPPER_KEY); | ||
| 215 | - SourcePortRangeBuilder srcPortRangeBuilder = new SourcePortRangeBuilder(); | ||
| 216 | - if (spRangeLowerStr != null) { | ||
| 217 | - int spRangeLower = Integer.parseInt(spRangeLowerStr); | ||
| 218 | - srcPortRangeBuilder.setLowerPort(new PortNumber(spRangeLower)); | ||
| 219 | - } | ||
| 220 | - if (spRangeUpperStr != null) { | ||
| 221 | - int spRangeUpper = Integer.parseInt(spRangeUpperStr); | ||
| 222 | - srcPortRangeBuilder.setUpperPort(new PortNumber(spRangeUpper)); | ||
| 223 | - } | ||
| 224 | - srcPortRange = srcPortRangeBuilder.build(); | ||
| 225 | - return srcPortRange; | ||
| 226 | - } | ||
| 227 | - | ||
| 228 | - /** | ||
| 229 | - * @param properties | ||
| 230 | - * @return destPortRange | ||
| 231 | - */ | ||
| 232 | - private DestinationPortRange getDestinationPortRange(Dictionary<?, ?> properties) { | ||
| 233 | - /** | ||
| 234 | - * Building Destination Port Range for given ACL model. | ||
| 235 | - */ | ||
| 236 | - String dpRangeLowerStr = get(properties, ACL_LIST_DP_LOWER_KEY); | ||
| 237 | - String dpRangeUpperStr = get(properties, ACL_LIST_DP_UPPER_KEY); | ||
| 238 | - DestinationPortRangeBuilder destPortRangeBuilder = new DestinationPortRangeBuilder(); | ||
| 239 | - if (dpRangeLowerStr != null) { | ||
| 240 | - int dpRangeLower = Integer.parseInt(dpRangeLowerStr); | ||
| 241 | - destPortRangeBuilder.setLowerPort(new PortNumber(dpRangeLower)); | ||
| 242 | - } | ||
| 243 | - if (dpRangeUpperStr != null) { | ||
| 244 | - int dpRangeUpper = Integer.parseInt(dpRangeUpperStr); | ||
| 245 | - destPortRangeBuilder.setUpperPort(new PortNumber(dpRangeUpper)); | ||
| 246 | - } | ||
| 247 | - destPortRange = destPortRangeBuilder.build(); | ||
| 248 | - return destPortRange; | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - /** | ||
| 252 | - * @param properties | ||
| 253 | - * @return accessListEntries | ||
| 254 | - */ | ||
| 255 | - private List<AccessListEntries> getAccessListEntries(Dictionary<?, ?> properties, | ||
| 256 | - Matches matches) { | ||
| 257 | - /** | ||
| 258 | - * Build and Populate Access List Entries. | ||
| 259 | - */ | ||
| 260 | - AccessListEntriesBuilder acLListEntriesBuilder = new AccessListEntriesBuilder(); | ||
| 261 | - String aclListEntriesRuleName = get(properties, | ||
| 262 | - ACL_LIST_ENTRIES_RULE_NAME_KEY); | ||
| 263 | - if (aclListEntriesRuleName != null) { | ||
| 264 | - acLListEntriesBuilder.setRuleName(aclListEntriesRuleName); | ||
| 265 | - } | ||
| 266 | - acLListEntriesBuilder.setMatches(matches); | ||
| 267 | - String aclActions = get(properties, ACL_LIST_ACTIONS_KEY); | ||
| 268 | - if (aclActions != null) { | ||
| 269 | - ActionsBuilder actionBuilder = new ActionsBuilder(); | ||
| 270 | - if (aclActions.equalsIgnoreCase("deny")) { | ||
| 271 | - DenyBuilder denyBuilder = new DenyBuilder(); | ||
| 272 | - actionBuilder.setPacketHandling(denyBuilder.build()); | ||
| 273 | - } else if (aclActions.equalsIgnoreCase("permit")) { | ||
| 274 | - PermitBuilder permitBuilder = new PermitBuilder(); | ||
| 275 | - actionBuilder.setPacketHandling(permitBuilder.build()); | ||
| 276 | - } | ||
| 277 | - acLListEntriesBuilder.setActions(actionBuilder.build()); | ||
| 278 | - } | ||
| 279 | - AccessListEntries aclListEntries = acLListEntriesBuilder.build(); | ||
| 280 | - List<AccessListEntries> accessListEntries = new ArrayList<AccessListEntries>(); | ||
| 281 | - accessListEntries.add(aclListEntries); | ||
| 282 | - return accessListEntries; | ||
| 283 | - } | ||
| 284 | - | ||
| 285 | - /** | ||
| 286 | - * @param properties | ||
| 287 | - * @return aceIp | ||
| 288 | - */ | ||
| 289 | - private AceIp getAceIp(Dictionary<?, ?> properties, | ||
| 290 | - SourcePortRange srcPortRange, | ||
| 291 | - DestinationPortRange destPortRange) { | ||
| 292 | - /** | ||
| 293 | - * Building Ace IPV4 Type | ||
| 294 | - */ | ||
| 295 | - String destIpv4 = get(properties, ACL_LIST_DEST_IPV4_KEY); | ||
| 296 | - String srcIpv4 = get(properties, ACL_LIST_SRC_IPV4_KEY); | ||
| 297 | - AceIpv4Builder aceIpv4Builder = new AceIpv4Builder(); | ||
| 298 | - aceIp = null; | ||
| 299 | - if (destIpv4 != null) { | ||
| 300 | - Ipv4Prefix destinationIp = new Ipv4Prefix(destIpv4); | ||
| 301 | - aceIpv4Builder.setDestinationIpv4Address(destinationIp); | ||
| 302 | - } | ||
| 303 | - if (srcIpv4 != null) { | ||
| 304 | - Ipv4Prefix sourceIp = new Ipv4Prefix(srcIpv4); | ||
| 305 | - aceIpv4Builder.setSourceIpv4Address(sourceIp); | ||
| 306 | - } | ||
| 307 | - if (destIpv4 != null || srcIpv4 != null) { | ||
| 308 | - AceIpv4 aceIpv4 = aceIpv4Builder.build(); | ||
| 309 | - AceIpBuilder aceIpBuilder = new AceIpBuilder(); | ||
| 310 | - aceIpBuilder.setAceIpVersion(aceIpv4); | ||
| 311 | - aceIpBuilder.setSourcePortRange(srcPortRange); | ||
| 312 | - aceIpBuilder.setDestinationPortRange(destPortRange); | ||
| 313 | - aceIp = aceIpBuilder.build(); | ||
| 314 | - } | ||
| 315 | - return aceIp; | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | - /** | ||
| 319 | - * @param deviceEntry | ||
| 320 | - * @return deviceMap | ||
| 321 | - */ | ||
| 322 | - private Map<String, String> processDeviceEntry(String deviceEntry) { | ||
| 323 | - if (deviceEntry == null) { | ||
| 324 | - log.info("No content for Device Entry, so cannot proceed further."); | ||
| 325 | - return null; | ||
| 326 | - } | ||
| 327 | - | ||
| 328 | - Map<String, String> deviceMap = new HashMap<String, String>(); | ||
| 329 | - log.info("Trying to convert Device Entry String: " + deviceEntry | ||
| 330 | - + " to a Netconf Device Object"); | ||
| 331 | - try { | ||
| 332 | - URI uri = new URI(deviceEntry); | ||
| 333 | - String path = uri.getPath(); | ||
| 334 | - String userInfo = path.substring(path.lastIndexOf('@')); | ||
| 335 | - String hostInfo = path.substring(path.lastIndexOf('@') + 1); | ||
| 336 | - String[] infoSplit = userInfo.split(":"); | ||
| 337 | - String username = infoSplit[0]; | ||
| 338 | - String password = infoSplit[1]; | ||
| 339 | - infoSplit = hostInfo.split(":"); | ||
| 340 | - String hostIp = infoSplit[0]; | ||
| 341 | - String hostPort = infoSplit[1]; | ||
| 342 | - if (isNullOrEmpty(username) || isNullOrEmpty(password) | ||
| 343 | - || isNullOrEmpty(hostIp) || isNullOrEmpty(hostPort)) { | ||
| 344 | - log.warn("Bad Configuration Data: both user and device" | ||
| 345 | - + " information parts of Configuration " + deviceEntry | ||
| 346 | - + " should be non-nullable"); | ||
| 347 | - } else { | ||
| 348 | - deviceMap.put("hostIp", hostIp); | ||
| 349 | - deviceMap.put("hostPort", hostPort); | ||
| 350 | - deviceMap.put("username", username); | ||
| 351 | - deviceMap.put("password", password); | ||
| 352 | - } | ||
| 353 | - } catch (ArrayIndexOutOfBoundsException aie) { | ||
| 354 | - log.error("Error while reading config infromation from the config file: " | ||
| 355 | - + "The user, host and device state infomation should be " | ||
| 356 | - + "in the order 'userInfo@hostInfo:deviceState'" | ||
| 357 | - + deviceEntry, aie); | ||
| 358 | - } catch (URISyntaxException urie) { | ||
| 359 | - log.error("Error while parsing config information for the device entry: " | ||
| 360 | - + "Illegal character in path " + deviceEntry, | ||
| 361 | - urie); | ||
| 362 | - } catch (Exception e) { | ||
| 363 | - log.error("Error while parsing config information for the device entry: " | ||
| 364 | - + deviceEntry, e); | ||
| 365 | - } | ||
| 366 | - return deviceMap; | ||
| 367 | - } | ||
| 368 | - | ||
| 369 | - @Override | ||
| 370 | - public void applyFlowRule(FlowRule... flowRules) { | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - @Override | ||
| 374 | - public void removeFlowRule(FlowRule... flowRules) { | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - private void applyRule() { | ||
| 378 | - // applyFlowRule(flowRules);//currentl | ||
| 379 | - } | ||
| 380 | - | ||
| 381 | - @Override | ||
| 382 | - public void removeRulesById(ApplicationId id, FlowRule... flowRules) { | ||
| 383 | - log.info("removal by app id not supported in null provider"); | ||
| 384 | - } | ||
| 385 | - | ||
| 386 | - @Override | ||
| 387 | - public void executeBatch(FlowRuleBatchOperation batch) { | ||
| 388 | - | ||
| 389 | - } | ||
| 390 | - | ||
| 391 | - private class StatisticTask implements TimerTask { | ||
| 392 | - | ||
| 393 | - @Override | ||
| 394 | - public void run(Timeout to) throws Exception { | ||
| 395 | - for (DeviceId devId : flowTable.keySet()) { | ||
| 396 | - providerService.pushFlowMetrics(devId, flowTable | ||
| 397 | - .getOrDefault(devId, Collections.emptySet())); | ||
| 398 | - } | ||
| 399 | - timeout = timer.newTimeout(to.getTask(), 5, TimeUnit.SECONDS); | ||
| 400 | - | ||
| 401 | - } | ||
| 402 | - } | ||
| 403 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.provider.netconf.flow.impl; | ||
| 17 | - | ||
| 18 | -import static org.onlab.util.Tools.delay; | ||
| 19 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 20 | - | ||
| 21 | -import java.io.IOException; | ||
| 22 | - | ||
| 23 | -import org.slf4j.Logger; | ||
| 24 | - | ||
| 25 | -import com.tailf.jnc.Capabilities; | ||
| 26 | -import com.tailf.jnc.JNCException; | ||
| 27 | -import com.tailf.jnc.SSHConnection; | ||
| 28 | -import com.tailf.jnc.SSHSession; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * This is to carry necessary information to connect and execute NETCONF | ||
| 32 | - * operations. | ||
| 33 | - */ | ||
| 34 | -public class NetconfOperation { | ||
| 35 | - private final Logger log = getLogger(NetconfOperation.class); | ||
| 36 | - private static final int EVENTINTERVAL = 2000; | ||
| 37 | - private static final int CONNECTION_CHECK_INTERVAL = 3; | ||
| 38 | - private static final String INPUT_HELLO_XML_MSG = new StringBuilder( | ||
| 39 | - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>") | ||
| 40 | - .append("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">") | ||
| 41 | - .append("<capabilities><capability>urn:ietf:params:netconf:base:1.0</capability>") | ||
| 42 | - .append("</capabilities></hello>").toString(); | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * This will send a Xml message to the device. | ||
| 46 | - * @param xmlMsg XML to send | ||
| 47 | - * @param username user name | ||
| 48 | - * @param password pass word | ||
| 49 | - * @param deviceIp ip address of the device | ||
| 50 | - * @param devicePort port on the device | ||
| 51 | - */ | ||
| 52 | - protected void sendXmlMessage(String xmlMsg, String username, | ||
| 53 | - String password, String deviceIp, | ||
| 54 | - Integer devicePort) { | ||
| 55 | - SSHSession ssh = null; | ||
| 56 | - try { | ||
| 57 | - SSHConnection sshConnection = getConnection(username, password, | ||
| 58 | - deviceIp, devicePort); | ||
| 59 | - ssh = new SSHSession(sshConnection); | ||
| 60 | - executeMessage(ssh, INPUT_HELLO_XML_MSG); | ||
| 61 | - /* | ||
| 62 | - * execute acl message | ||
| 63 | - */ | ||
| 64 | - executeMessage(ssh, xmlMsg); | ||
| 65 | - | ||
| 66 | - } catch (IOException e) { | ||
| 67 | - log.error("Unable to send Hello Message to the device: ", e); | ||
| 68 | - } catch (JNCException e) { | ||
| 69 | - log.error("Authentication fail while sending Hello Message to the device: ", | ||
| 70 | - e); | ||
| 71 | - } catch (Exception e) { | ||
| 72 | - log.error("Unable to send Hello Message to the device: ", e); | ||
| 73 | - } finally { | ||
| 74 | - log.debug("Closing the session after successful execution"); | ||
| 75 | - if (ssh != null) { | ||
| 76 | - ssh.close(); | ||
| 77 | - } | ||
| 78 | - } | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - private void executeMessage(SSHSession ssh, String xmlMsg) | ||
| 82 | - throws IOException, JNCException { | ||
| 83 | - String helloRequestXML = xmlMsg.trim(); | ||
| 84 | - | ||
| 85 | - log.debug("Sending Hello"); | ||
| 86 | - ssh.print(helloRequestXML); | ||
| 87 | - ssh.flush(); | ||
| 88 | - String xmlResponse = null; | ||
| 89 | - int i = CONNECTION_CHECK_INTERVAL; | ||
| 90 | - while (!ssh.ready() && i > 0) { | ||
| 91 | - delay(EVENTINTERVAL); | ||
| 92 | - i--; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - if (ssh.ready()) { | ||
| 96 | - StringBuffer readOne = ssh.readOne(); | ||
| 97 | - if (readOne == null) { | ||
| 98 | - log.error("The Hello Contains No Capabilites"); | ||
| 99 | - throw new JNCException( | ||
| 100 | - JNCException.SESSION_ERROR, | ||
| 101 | - "server does not support NETCONF base capability: " | ||
| 102 | - + Capabilities.NETCONF_BASE_CAPABILITY); | ||
| 103 | - } else { | ||
| 104 | - xmlResponse = readOne.toString().trim(); | ||
| 105 | - | ||
| 106 | - log.debug("Reading Capabilities: " | ||
| 107 | - + ssh.getSSHConnection().getGanymedConnection() | ||
| 108 | - .getHostname()); | ||
| 109 | - } | ||
| 110 | - } | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - /** | ||
| 114 | - * To establish SSH Connection. | ||
| 115 | - * | ||
| 116 | - * @param username user name | ||
| 117 | - * @param password pass word | ||
| 118 | - * @param sshHost host | ||
| 119 | - * @param sshPort port | ||
| 120 | - * @return new SSH connection | ||
| 121 | - * @throws IOException if connection fails | ||
| 122 | - * @throws JNCException if connection causes an error | ||
| 123 | - */ | ||
| 124 | - public SSHConnection getConnection(String username, String password, | ||
| 125 | - String sshHost, Integer sshPort) | ||
| 126 | - throws IOException, JNCException { | ||
| 127 | - SSHConnection sshConnection; | ||
| 128 | - try { | ||
| 129 | - sshConnection = new SSHConnection(sshHost, sshPort); | ||
| 130 | - sshConnection.authenticateWithPassword(username, password); | ||
| 131 | - } catch (IOException e) { | ||
| 132 | - log.error("Unable to create a connection to the device: "); | ||
| 133 | - throw e; | ||
| 134 | - } catch (JNCException e) { | ||
| 135 | - log.error("Failed to connect to the device: "); | ||
| 136 | - throw e; | ||
| 137 | - } | ||
| 138 | - return sshConnection; | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.provider.netconf.flow.impl; | ||
| 17 | - | ||
| 18 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | - | ||
| 20 | -import org.jdom2.Document; | ||
| 21 | -import org.jdom2.Element; | ||
| 22 | -import org.jdom2.Namespace; | ||
| 23 | -import org.jdom2.output.Format; | ||
| 24 | -import org.jdom2.output.XMLOutputter; | ||
| 25 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.AccessList; | ||
| 26 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.AceType; | ||
| 27 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.AceEth; | ||
| 28 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.AceIp; | ||
| 29 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.AceIpVersion; | ||
| 30 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.ace.ip.version.AceIpv4; | ||
| 31 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev140520.access.list.access.list.entries.matches.ace.type.ace.ip.ace.ip.version.AceIpv6; | ||
| 32 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; | ||
| 33 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.DestinationPortRange; | ||
| 34 | -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.packet.fields.rev140625.acl.transport.header.fields.SourcePortRange; | ||
| 35 | -import org.slf4j.Logger; | ||
| 36 | - | ||
| 37 | -/** | ||
| 38 | - * Xml Builder to generate the xml according to given ACL model. | ||
| 39 | - */ | ||
| 40 | -public class XmlBuilder { | ||
| 41 | - private final Logger log = getLogger(XmlBuilder.class); | ||
| 42 | - | ||
| 43 | - public String buildAclRequestXml(AccessList accessList) { | ||
| 44 | - Document doc = new Document(); | ||
| 45 | - Namespace namespaceRpc = Namespace | ||
| 46 | - .getNamespace("urn:ietf:params:xml:ns:netconf:base:1.0"); | ||
| 47 | - Namespace accessNamespaceRpc = Namespace | ||
| 48 | - .getNamespace("urn:ietf:params:xml:ns:yang:ietf-acl"); | ||
| 49 | - doc.setRootElement(new Element("rpc", namespaceRpc) | ||
| 50 | - .setAttribute("message-id", "101")); | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | - * Access list elements of given ACL model. | ||
| 54 | - */ | ||
| 55 | - Element access = new Element("access-list", accessNamespaceRpc); | ||
| 56 | - access.addContent(new Element("acl-name", accessNamespaceRpc) | ||
| 57 | - .setText(accessList.getAclName())); | ||
| 58 | - // access.addContent(accessEntries); | ||
| 59 | - | ||
| 60 | - if (!accessList.getAccessListEntries().isEmpty() | ||
| 61 | - && accessList.getAccessListEntries() != null) { | ||
| 62 | - for (int accessEntryIntVlu = 0; accessEntryIntVlu < accessList | ||
| 63 | - .getAccessListEntries().size(); accessEntryIntVlu++) { | ||
| 64 | - access.addContent(getAccessEntries(accessEntryIntVlu, | ||
| 65 | - accessList, | ||
| 66 | - accessNamespaceRpc)); | ||
| 67 | - } | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * edit-config operation for given ACL model. | ||
| 72 | - */ | ||
| 73 | - Element editConfig = new Element("edit-config", namespaceRpc); | ||
| 74 | - editConfig.addContent(new Element("target", namespaceRpc) | ||
| 75 | - .addContent(new Element("running", namespaceRpc))); | ||
| 76 | - editConfig.addContent(new Element("config", Namespace | ||
| 77 | - .getNamespace("urn:ietf:params:xml:ns:netconf:base:1.0")) | ||
| 78 | - .addContent(access)); | ||
| 79 | - | ||
| 80 | - doc.getRootElement().addContent(editConfig); | ||
| 81 | - XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); | ||
| 82 | - String outputString = xmlOutputter.outputString(doc); | ||
| 83 | - | ||
| 84 | - return outputString; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - /** | ||
| 88 | - * access entries operation for given ACL model. | ||
| 89 | - */ | ||
| 90 | - private Element getAccessEntries(int accessEntryIntVlu, | ||
| 91 | - AccessList accessList, | ||
| 92 | - Namespace accessNamespaceRpc) { | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * Port Number | ||
| 96 | - */ | ||
| 97 | - | ||
| 98 | - int srcPortRangeLower = 0; | ||
| 99 | - int srcPortRangeUpper = 0; | ||
| 100 | - int destPortRangeLower = 0; | ||
| 101 | - int destPortRangeUpper = 0; | ||
| 102 | - | ||
| 103 | - String sourceIpAdd = ""; | ||
| 104 | - String destinationIpAdd = ""; | ||
| 105 | - | ||
| 106 | - /* | ||
| 107 | - * checking accessList is null or not | ||
| 108 | - */ | ||
| 109 | - if (accessList != null) { | ||
| 110 | - /* | ||
| 111 | - * checking list entries are empty or null | ||
| 112 | - */ | ||
| 113 | - if (!accessList.getAccessListEntries().isEmpty() | ||
| 114 | - && accessList.getAccessListEntries() != null) { | ||
| 115 | - AceType aceType = accessList.getAccessListEntries() | ||
| 116 | - .get(accessEntryIntVlu).getMatches().getAceType(); | ||
| 117 | - | ||
| 118 | - if (aceType instanceof AceIp) { | ||
| 119 | - AceIp aceIp = (AceIp) aceType; | ||
| 120 | - SourcePortRange sourcePortRange = aceIp | ||
| 121 | - .getSourcePortRange(); | ||
| 122 | - if (sourcePortRange != null) { | ||
| 123 | - PortNumber lowerPort = sourcePortRange.getLowerPort(); | ||
| 124 | - PortNumber upperPort = sourcePortRange.getUpperPort(); | ||
| 125 | - | ||
| 126 | - if (lowerPort != null) { | ||
| 127 | - srcPortRangeLower = lowerPort.getValue(); | ||
| 128 | - } | ||
| 129 | - if (upperPort != null) { | ||
| 130 | - srcPortRangeUpper = upperPort.getValue(); | ||
| 131 | - } | ||
| 132 | - } | ||
| 133 | - DestinationPortRange destinationPortRange = aceIp | ||
| 134 | - .getDestinationPortRange(); | ||
| 135 | - | ||
| 136 | - if (destinationPortRange != null) { | ||
| 137 | - PortNumber lowerPort = destinationPortRange | ||
| 138 | - .getLowerPort(); | ||
| 139 | - if (lowerPort != null) { | ||
| 140 | - destPortRangeLower = lowerPort.getValue(); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - PortNumber upperPort = destinationPortRange | ||
| 144 | - .getUpperPort(); | ||
| 145 | - if (upperPort != null) { | ||
| 146 | - destPortRangeUpper = upperPort.getValue(); | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - AceIpVersion aceIpVersion = aceIp.getAceIpVersion(); | ||
| 152 | - if (aceIpVersion instanceof AceIpv4) { | ||
| 153 | - AceIpv4 obj = (AceIpv4) aceIpVersion; | ||
| 154 | - destinationIpAdd = obj.getDestinationIpv4Address() | ||
| 155 | - .getValue(); | ||
| 156 | - sourceIpAdd = obj.getSourceIpv4Address().getValue(); | ||
| 157 | - } else if (aceIpVersion instanceof AceIpv6) { | ||
| 158 | - AceIpv6 obj = (AceIpv6) aceIpVersion; | ||
| 159 | - destinationIpAdd = obj.getDestinationIpv6Address() | ||
| 160 | - .getValue(); | ||
| 161 | - sourceIpAdd = obj.getSourceIpv6Address().getValue(); | ||
| 162 | - } | ||
| 163 | - } else if (aceType instanceof AceEth) { | ||
| 164 | - log.debug("Need to add execution loging for Ace Type Ethernet"); | ||
| 165 | - } | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - /** | ||
| 170 | - * Matches elements to define IP address & Port range for given ACL | ||
| 171 | - * model. | ||
| 172 | - */ | ||
| 173 | - Element matchesElement = new Element("matches", accessNamespaceRpc); | ||
| 174 | - if (String.valueOf(srcPortRangeLower) != null | ||
| 175 | - && !String.valueOf(srcPortRangeLower).isEmpty()) { | ||
| 176 | - | ||
| 177 | - matchesElement.addContent(new Element("source-port-range", | ||
| 178 | - accessNamespaceRpc) | ||
| 179 | - .addContent(new Element("lower-port", accessNamespaceRpc) | ||
| 180 | - .setText(String.valueOf(srcPortRangeLower)))); | ||
| 181 | - | ||
| 182 | - matchesElement.addContent(new Element("source-port-range", | ||
| 183 | - accessNamespaceRpc) | ||
| 184 | - .addContent(new Element("upper-port", accessNamespaceRpc) | ||
| 185 | - .setText(String.valueOf(srcPortRangeUpper)))); | ||
| 186 | - | ||
| 187 | - matchesElement.addContent(new Element("destination-port-range", | ||
| 188 | - accessNamespaceRpc) | ||
| 189 | - .addContent(new Element("lower-port", accessNamespaceRpc) | ||
| 190 | - .setText(String.valueOf(destPortRangeLower)))); | ||
| 191 | - | ||
| 192 | - matchesElement.addContent(new Element("destination-port-range", | ||
| 193 | - accessNamespaceRpc) | ||
| 194 | - .addContent(new Element("upper-port", accessNamespaceRpc) | ||
| 195 | - .setText(String.valueOf(destPortRangeUpper)))); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - if (destinationIpAdd != null && !destinationIpAdd.isEmpty()) { | ||
| 199 | - matchesElement.addContent(new Element("destination-ipv4-address", | ||
| 200 | - accessNamespaceRpc) | ||
| 201 | - .setText(destinationIpAdd)); | ||
| 202 | - } | ||
| 203 | - if (sourceIpAdd != null && !sourceIpAdd.isEmpty()) { | ||
| 204 | - matchesElement.addContent(new Element("source-ipv4-address", | ||
| 205 | - accessNamespaceRpc) | ||
| 206 | - .setText(sourceIpAdd)); | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - /** | ||
| 210 | - * Access entries elements for given ACL model. | ||
| 211 | - */ | ||
| 212 | - Element accessEntries = new Element("access-list-entries", | ||
| 213 | - accessNamespaceRpc); | ||
| 214 | - accessEntries.addContent(new Element("rule-name", accessNamespaceRpc) | ||
| 215 | - .setText(accessList.getAccessListEntries() | ||
| 216 | - .get(accessEntryIntVlu).getRuleName())); | ||
| 217 | - accessEntries.addContent(matchesElement); | ||
| 218 | - accessEntries.addContent(new Element("actions", accessNamespaceRpc) | ||
| 219 | - .addContent(new Element("deny", accessNamespaceRpc))); | ||
| 220 | - | ||
| 221 | - return accessEntries; | ||
| 222 | - } | ||
| 223 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * Provider that will accept any flow rules. | ||
| 19 | - */ | ||
| 20 | -package org.onosproject.provider.netconf.flow.impl; | ||
| 21 | - |
-
Please register or login to post a comment