From: Giovanni Meo Date: Thu, 7 Nov 2013 11:15:56 +0000 (+0000) Subject: Merge "Ganymed patch fix" X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~472 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e87fa215eac79bc76b0addbb1f5beebfaa8ca5f7;hp=bc3d9508f699313c89843d3462443afc998c6933 Merge "Ganymed patch fix" --- diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 62b9ec34d0..9db5b76988 100755 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -29,6 +29,8 @@ yang-store-impl yang-test logback-config + threadpool-config-api + threadpool-config-impl diff --git a/opendaylight/config/threadpool-config-api/pom.xml b/opendaylight/config/threadpool-config-api/pom.xml new file mode 100644 index 0000000000..b991b69213 --- /dev/null +++ b/opendaylight/config/threadpool-config-api/pom.xml @@ -0,0 +1,51 @@ + + + org.opendaylight.controller + config-subsystem + 0.2.2-SNAPSHOT + + 4.0.0 + threadpool-config-api + ${project.artifactId} + bundle + + 3.0.4 + + + + + org.opendaylight.controller + config-api + + + com.google.guava + guava + + + + + + + org.apache.felix + maven-bundle-plugin + + + + org.opendaylight.controller.config.api.*, + com.google.common.eventbus, + + + org.opendaylight.controller.config.threadpool, + org.opendaylight.controller.config.yang.threadpool + + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + + \ No newline at end of file diff --git a/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java new file mode 100644 index 0000000000..bf6c016d35 --- /dev/null +++ b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ScheduledThreadPool.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2013 Cisco 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.controller.config.threadpool; + +import java.util.concurrent.ScheduledExecutorService; + +/** + * Interface representing scheduled {@link ThreadPool}. + */ +public interface ScheduledThreadPool extends ThreadPool { + + @Override + public ScheduledExecutorService getExecutor(); +} \ No newline at end of file diff --git a/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java new file mode 100644 index 0000000000..701b0bcdf8 --- /dev/null +++ b/opendaylight/config/threadpool-config-api/src/main/java/org/opendaylight/controller/config/threadpool/ThreadPool.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2013 Cisco 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.controller.config.threadpool; + +import java.util.concurrent.ExecutorService; + +/** + * Interface representing thread pool. + */ +public interface ThreadPool { + + public ExecutorService getExecutor(); + + public int getMaxThreadCount(); +} \ No newline at end of file diff --git a/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang b/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang new file mode 100644 index 0000000000..14a20fdebc --- /dev/null +++ b/opendaylight/config/threadpool-config-api/src/main/yang/threadpool.yang @@ -0,0 +1,77 @@ +// vi: set smarttab et sw=4 tabstop=4: +module threadpool { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool"; + prefix "th"; + + import config { prefix config; revision-date 2013-04-05; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + thread-related services. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-09" { + description + "Added eventbus service."; + } + + revision "2013-04-05" { + description + "Updated with YANG extension for Java class specification."; + } + + revision "2013-04-03" { + description + "Initial revision by Anton Tkacik, Tomas Olvecky and + Robert Varga."; + } + + identity eventbus { + description + "Service representing an event bus. The service acts as message + router between event producers and event consumers"; + + base "config:service-type"; + config:java-class "com.google.common.eventbus.EventBus"; + } + + identity threadfactory { + description + "Service representing a ThreadFactory instance. It is directly + useful in Java world, where various library pieces need to create + threads and you may want to inject a customized thread + implementation."; + + base "config:service-type"; + config:java-class "java.util.concurrent.ThreadFactory"; + } + + identity threadpool { + description + "A simple pool of threads able to execute work."; + + base "config:service-type"; + config:java-class "org.opendaylight.controller.config.threadpool.ThreadPool"; + } + + identity scheduled-threadpool { + description + "An extension of the simple pool of threads able to schedule + work to be executed at some point in time."; + + base "threadpool"; + config:java-class "org.opendaylight.controller.config.threadpool.ScheduledThreadPool"; + } + +} diff --git a/opendaylight/config/threadpool-config-impl/pom.xml b/opendaylight/config/threadpool-config-impl/pom.xml new file mode 100644 index 0000000000..12279781a2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/pom.xml @@ -0,0 +1,76 @@ + + + org.opendaylight.controller + config-subsystem + 0.2.2-SNAPSHOT + + 4.0.0 + threadpool-config-impl + ${project.artifactId} + bundle + + 3.0.4 + + + + + ${project.groupId} + config-api + + + ${project.groupId} + threadpool-config-api + ${project.version} + + + com.google.guava + guava + + + org.slf4j + slf4j-api + + + + + + + org.apache.felix + maven-bundle-plugin + + + + org.opendaylight.controller.config.threadpool.util, + javax.annotation.*, + org.opendaylight.controller.config.yang.threadpool.impl, + + + org.opendaylight.controller.config.api.*, + org.opendaylight.controller.config.spi.*, + org.opendaylight.controller.config.threadpool, + org.opendaylight.controller.config.yang.threadpool, + javax.management, + org.osgi.framework, + org.slf4j, + com.google.common.* + + + org.opendaylight.controller.config.threadpool.util + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.opendaylight.yangtools + yang-maven-plugin + + + + + \ No newline at end of file diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java new file mode 100644 index 0000000000..93a08daa5d --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableAsyncEventBus.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013 Cisco 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.controller.config.threadpool.util; + +import com.google.common.eventbus.AsyncEventBus; +import com.google.common.eventbus.DeadEvent; +import com.google.common.eventbus.Subscribe; + +import java.io.Closeable; +import java.io.IOException; + +import org.opendaylight.controller.config.threadpool.ThreadPool; +import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeMXBean; +import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistration; +import org.opendaylight.controller.config.yang.threadpool.impl.AsyncEventBusRuntimeRegistrator; + +/** + * Closeable version of {@link AsyncEventBus}. + */ +public class CloseableAsyncEventBus extends AsyncEventBus implements Closeable { + private final ThreadPool threadPool; + private final AsyncEventBusRuntimeRegistration rootRegistration; + + public CloseableAsyncEventBus(String identifier, ThreadPool threadPool, + AsyncEventBusRuntimeRegistrator rootRegistrator) { + super(identifier, threadPool.getExecutor()); + this.threadPool = threadPool; + rootRegistration = rootRegistrator.register(new AsyncEventBusRuntimeMXBean() { + private long deadEventsCounter = 0; + + @Subscribe + public void increaseDeadEvents(DeadEvent deadEvent) { + deadEventsCounter++; + } + + @Override + public Long countDeadEvents() { + return deadEventsCounter; + } + + }); + } + + public ThreadPool getThreadPool() { + return threadPool; + } + + @Override + public void close() throws IOException { + rootRegistration.close(); + } + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java new file mode 100644 index 0000000000..b6dd77dbf3 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/threadpool/util/CloseableEventBus.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Cisco 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.controller.config.threadpool.util; + +import java.io.Closeable; + +import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeMXBean; +import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistration; +import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistrator; + +import com.google.common.eventbus.DeadEvent; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +/** + * Closeable {@link EventBus}. + */ +public class CloseableEventBus extends EventBus implements Closeable { + + private final EventBusRuntimeRegistration rootRegistration; + + public CloseableEventBus(String identifier, EventBusRuntimeRegistrator rootRegistrator) { + super(identifier); + rootRegistration = rootRegistrator.register(new EventBusRuntimeMXBean() { + private long deadEventsCounter = 0; + + @Subscribe + public void increaseDeadEvents(DeadEvent deadEvent) { + deadEventsCounter++; + } + + @Override + public Long countDeadEvents() { + return deadEventsCounter; + } + }); + + } + + @Override + public void close() { + rootRegistration.close(); + + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java new file mode 100644 index 0000000000..f108303165 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModule.java @@ -0,0 +1,42 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: async-eventbus + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Tue Nov 05 15:40:46 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +import org.opendaylight.controller.config.threadpool.util.CloseableAsyncEventBus; + +/** +* +*/ +public final class AsyncEventBusModule extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModule { + + public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public AsyncEventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + AsyncEventBusModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + return new CloseableAsyncEventBus(getIdentifier().toString(), getThreadpoolDependency(), + getRootRuntimeBeanRegistratorWrapper()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java new file mode 100644 index 0000000000..14fcf41758 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/AsyncEventBusModuleFactory.java @@ -0,0 +1,18 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: async-eventbus + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Tue Nov 05 15:40:46 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +/** +* +*/ +public class AsyncEventBusModuleFactory extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractAsyncEventBusModuleFactory { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java new file mode 100644 index 0000000000..92eaee5ef2 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModule.java @@ -0,0 +1,41 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: eventbus + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Tue Nov 05 15:40:46 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +import org.opendaylight.controller.config.threadpool.util.CloseableEventBus; + +/** +* +*/ +public final class EventBusModule extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModule { + + public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public EventBusModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, EventBusModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + return new CloseableEventBus(getIdentifier().toString(), getRootRuntimeBeanRegistratorWrapper()); + } +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java new file mode 100644 index 0000000000..e909998a72 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/java/org/opendaylight/controller/config/yang/threadpool/impl/EventBusModuleFactory.java @@ -0,0 +1,18 @@ +/** + * Generated file + + * Generated from: yang module name: threadpool-impl yang module local name: eventbus + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Tue Nov 05 15:40:46 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.threadpool.impl; + +/** +* +*/ +public class EventBusModuleFactory extends + org.opendaylight.controller.config.yang.threadpool.impl.AbstractEventBusModuleFactory { + +} diff --git a/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang new file mode 100644 index 0000000000..4695564144 --- /dev/null +++ b/opendaylight/config/threadpool-config-impl/src/main/yang/threadpool-impl.yang @@ -0,0 +1,104 @@ +// vi: set smarttab et sw=4 tabstop=4: +module threadpool-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl"; + prefix "th-java"; + + import threadpool { prefix th; revision-date 2013-04-09; } + import config { prefix config; revision-date 2013-04-05; } + import rpc-context { prefix rpcx; revision-date 2013-06-17; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + thread services pure Java implementation. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-05" { + description + "Updated to work with new anchors."; + } + + revision "2013-04-03" { + description + "Initial revision by Anton Tkacik, Tomas Olvecky and + Robert Varga."; + } + + identity eventbus { + base config:module-type; + config:provided-service th:eventbus; + config:java-name-prefix EventBus; + } + + augment "/config:modules/config:module/config:configuration" { + case eventbus { + when "/config:modules/config:module/config:type = 'eventbus'"; + // No real configuration + } + } + + augment "/config:modules/config:module/config:state" { + case eventbus { + when "/config:modules/config:module/config:type = 'eventbus'"; + rpcx:rpc-context-instance "event-bus-rpc"; + } + } + + identity event-bus-rpc; + + identity async-eventbus { + base config:module-type; + config:provided-service th:eventbus; + config:java-name-prefix AsyncEventBus; + } + + augment "/config:modules/config:module/config:configuration" { + case async-eventbus { + when "/config:modules/config:module/config:type = 'async-eventbus'"; + container threadpool { + uses config:service-ref { + refine type { + //mandatory true; + config:required-identity th:threadpool; + } + } + } + } + } + + augment "/config:modules/config:module/config:state" { + case async-eventbus { + when "/config:modules/config:module/config:type = 'async-eventbus'"; + rpcx:rpc-context-instance "event-bus-rpc"; + } + } + + + + rpc get-dead-events-count { + config:java-name-prefix countDeadEvents; + input { + uses rpcx:rpc-context-ref { + refine context-instance { + rpcx:rpc-context-instance event-bus-rpc; + } + } + } + output { + leaf result { + type uint32; + } + } + } +} + diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index 4482df0780..9b07f75c6d 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -81,7 +81,7 @@ org.opendaylight.controller - sal-compability + sal-compatibility ${mdsal.version} diff --git a/opendaylight/md-sal/flow-management-compatibility/pom.xml b/opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml similarity index 94% rename from opendaylight/md-sal/flow-management-compatibility/pom.xml rename to opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml index 5c24baa650..3c8bf97961 100644 --- a/opendaylight/md-sal/flow-management-compatibility/pom.xml +++ b/opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml @@ -2,8 +2,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.opendaylight.controller - sal-parent + org.opendaylight.controller + compatibility-parent 1.0-SNAPSHOT flow-management-compatibility @@ -81,7 +81,7 @@ org.opendaylight.controller - sal-compability + sal-compatibility 1.0-SNAPSHOT diff --git a/opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend similarity index 98% rename from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend rename to opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend index 58248590a1..d462251a9f 100644 --- a/opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend +++ b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend @@ -15,7 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager import static com.google.common.base.Preconditions.*; import static extension org.opendaylight.controller.md.frm.compatibility.FlowConfigMapping.*; -import static extension org.opendaylight.controller.sal.compability.NodeMapping.*; +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*; import org.opendaylight.controller.sal.common.util.Arguments import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem import org.opendaylight.yangtools.yang.common.RpcResult diff --git a/opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend similarity index 89% rename from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend rename to opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend index c567dc0097..e4d9173378 100644 --- a/opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend +++ b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend @@ -3,9 +3,9 @@ package org.opendaylight.controller.md.frm.compatibility import org.opendaylight.controller.forwardingrulesmanager.FlowConfig import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder -import static extension org.opendaylight.controller.sal.compability.NodeMapping.* -import static org.opendaylight.controller.sal.compability.MDFlowMapping.* -import static org.opendaylight.controller.sal.compability.ToSalConversionsUtils.* +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* +import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.* +import static org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.* import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow diff --git a/opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java similarity index 100% rename from opendaylight/md-sal/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java rename to opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java new file mode 100644 index 0000000000..a82eedc3f9 --- /dev/null +++ b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/SampleConsumer.java @@ -0,0 +1,38 @@ +package org.opendaylight.controller.md.frm.compatibility; + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; +import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class SampleConsumer { + + ConsumerContext context; + + void addFlowExample() { + + DataBrokerService dataService = context.getSALService(DataBrokerService.class); + + DataModificationTransaction transaction = dataService.beginTransaction(); + Flow flow = createSampleFlow("foo", null); + InstanceIdentifier path = InstanceIdentifier.builder().node(Flows.class).node(Flow.class, flow.getKey()) + .toInstance(); + transaction.putConfigurationData(path, flow); + + transaction.commit(); + + dataService.readConfigurationData(path); + } + + Flow createSampleFlow(String name, NodeRef node) { + FlowBuilder ret = new FlowBuilder(); + FlowKey key = new FlowKey(name, node); + ret.setKey(key); + return ret.build(); + } +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml new file mode 100644 index 0000000000..d9fb18f84d --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/pom.xml @@ -0,0 +1,109 @@ + + 4.0.0 + + org.opendaylight.controller + compatibility-parent + 1.0-SNAPSHOT + + inventory-topology-compatibility + bundle + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + + + + + org.apache.felix + maven-bundle-plugin + true + + + Forwarding Rules Manager Adapter + for MD-SAL + + + + + org.eclipse.xtend + xtend-maven-plugin + + + maven-clean-plugin + + + + + + + org.opendaylight.controller + sal-common-util + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-binding-api + 1.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.6.1-SNAPSHOT + + + org.opendaylight.controller + topologymanager + 0.4.1-SNAPSHOT + + + org.slf4j + slf4j-api + + + com.google.guava + guava + + + junit + junit + test + + + org.mockito + mockito-all + test + + + org.eclipse.xtend + org.eclipse.xtend.lib + + + org.opendaylight.controller.model + model-flow-management + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-binding-util + 1.0-SNAPSHOT + + + org.opendaylight.controller.model + model-topology + 1.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager + 0.4.1-SNAPSHOT + + + org.opendaylight.controller + sal-compatibility + 1.0-SNAPSHOT + + + diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend new file mode 100644 index 0000000000..430b5957ef --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/CompatibleSwitchManager.xtend @@ -0,0 +1,289 @@ +package org.opendaylight.controller.md.compatibility.switchmanager + +import org.opendaylight.controller.switchmanager.ISwitchManager +import org.opendaylight.controller.sal.core.NodeConnector +import org.opendaylight.controller.sal.core.Property +import java.util.List +import org.opendaylight.controller.sal.core.Node +import java.net.InetAddress +import org.opendaylight.controller.sal.binding.api.data.DataBrokerService +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* +import org.opendaylight.controller.sal.core.Description +import org.opendaylight.controller.sal.core.Tier +import org.opendaylight.controller.sal.core.Bandwidth +import org.opendaylight.controller.sal.core.ForwardingMode +import org.opendaylight.controller.sal.core.MacAddress + +import org.slf4j.LoggerFactory +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier +import org.opendaylight.yangtools.yang.binding.DataObject +import java.net.NetworkInterface +import java.net.SocketException +import java.util.Collections +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes +import java.util.ArrayList +import org.opendaylight.controller.switchmanager.Switch +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId +import java.util.Map +import java.util.HashSet +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState + +class CompatibleSwitchManager extends ConfigurableSwitchManager implements ISwitchManager { + + private static val log = LoggerFactory.getLogger(CompatibleSwitchManager) + + @org.eclipse.xtend.lib.Property + var DataBrokerService dataService; + + override addNodeConnectorProp(NodeConnector nodeConnector, Property prop) { + val it = dataService.beginTransaction + val path = nodeConnector.toNodeConnectorRef + + // TODO: Update FlowCapableNode + return null; + } + + override createProperty(String propName, String propValue) { + try { + if (propName.equalsIgnoreCase(Description.propertyName)) { + return new Description(propValue); + } else if (propName.equalsIgnoreCase(Tier.TierPropName)) { + val tier = Integer.parseInt(propValue); + return new Tier(tier); + } else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) { + val bw = Long.parseLong(propValue); + return new Bandwidth(bw); + } else if (propName.equalsIgnoreCase(ForwardingMode.name)) { + val mode = Integer.parseInt(propValue); + return new ForwardingMode(mode); + } else if (propName.equalsIgnoreCase(MacAddress.name)) { + return new MacAddress(propValue); + } else { + log.debug("Not able to create {} property", propName); + } + } catch (Exception e) { + log.debug("createProperty caught exception {}", e.getMessage()); + } + return null; + } + + override doesNodeConnectorExist(NodeConnector nc) { + val ref = nc.toNodeConnectorRef + return dataService.readOperationalData(ref.value as InstanceIdentifier) !== null + } + + override getControllerMAC() { + var byte[] macAddress = null; + + try { + val nis = NetworkInterface.getNetworkInterfaces(); + while (nis.hasMoreElements()) { + val ni = nis.nextElement(); + try { + macAddress = ni.getHardwareAddress(); + return macAddress; + } catch (SocketException e) { + log.error("Failed to acquire controller MAC: ", e); + } + } + } catch (SocketException e) { + log.error("Failed to acquire controller MAC: ", e); + return macAddress; + } + + if (macAddress == null) { + log.warn("Failed to acquire controller MAC: No physical interface found"); + + // This happens when running controller on windows VM, for example + // Try parsing the OS command output + } + return macAddress; + } + + override getControllerProperties() { + return Collections.emptyMap() + } + + override getControllerProperty(String propertyName) { + return null; + } + + override getNetworkDevices() { + val path = InstanceIdentifier.builder().node(Nodes).toInstance; + val data = dataService.readOperationalData(path) as Nodes; + val ret = new ArrayList(); + for (node : data.node) { + ret.add(node.toSwitch()); + } + return ret; + } + + override getNodeConnector(Node node, String nodeConnectorName) { + val key = new NodeConnectorKey(new NodeConnectorId(nodeConnectorName)); + return new NodeConnector(MD_SAL_TYPE, key, node); + } + + override getNodeConnectorProp(NodeConnector nodeConnector, String propName) { + getNodeConnectorProps(nodeConnector).get(propName); + } + + override getNodeConnectorProps(NodeConnector nodeConnector) { + val ref = nodeConnector.toNodeConnectorRef + val data = readNodeConnector(ref.value); + return data.toAdProperties(); + } + + override getNodeConnectors(Node node) { + val ref = node.toNodeRef; + val data = readNode(ref.value); + val ret = new HashSet(); + for (nc : data.nodeConnector) { + + val adConnector = new NodeConnector(MD_SAL_TYPE, nc.key, node); + ret.add(adConnector); + } + return ret; + } + + override getNodeDescription(Node node) { + (getNodeProps(node).get(Description.propertyName) as Description).value; + } + + override getNodeMAC(Node node) { + (getNodeProps(node).get(MacAddress.name) as MacAddress).macAddress; + } + + override getNodeProp(Node node, String propName) { + getNodeProps(node).get(propName) + } + + override getNodeProps(Node node) { + val ref = node.toNodeRef; + val data = dataService.readOperationalData(ref.value as InstanceIdentifier) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; + return data.toAdProperties(); + } + + override getNodes() { + val path = InstanceIdentifier.builder().node(Nodes).toInstance; + val data = dataService.readOperationalData(path) as Nodes; + val ret = new HashSet(); + for (node : data.node) { + ret.add(new Node(MD_SAL_TYPE, node.key)); + } + return ret; + } + + def Switch toSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node node) { + val adNode = new Node(MD_SAL_TYPE, node.key); + val sw = new Switch(adNode) + return sw; + } + + override getPhysicalNodeConnectors(Node node) { + val ref = node.toNodeRef; + val data = readNode(ref.value); + val ret = new HashSet(); + for (nc : data.nodeConnector) { + val flowConnector = nc.getAugmentation(FlowCapableNodeConnector) + val adConnector = new NodeConnector(MD_SAL_TYPE, nc.key, node); + ret.add(adConnector); + } + return ret; + } + + def Map toAdProperties( + org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector connector) { + return Collections.emptyMap + } + + def Map toAdProperties( + org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node connector) { + return Collections.emptyMap + } + + def readNode(InstanceIdentifier ref) { + dataService.readOperationalData(ref as InstanceIdentifier) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node + } + + def readNodeConnector(InstanceIdentifier ref) { + dataService.readOperationalData(ref as InstanceIdentifier) as org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector + } + + override getSpanPorts(Node node) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override getSubnetByNetworkAddress(InetAddress networkAddress) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override getUpNodeConnectors(Node node) { + val ref = node.toNodeRef + val data = readNode(ref.value); + val ret = new HashSet(); + for (nc : data.nodeConnector) { + val flowConn = nc.getAugmentation(FlowCapableNodeConnector); + if (flowConn != null && flowConn.state == PortState.Live) { + ret.add(new NodeConnector(MD_SAL_TYPE, nc.key, node)); + } + } + return ret; + } + + override isNodeConnectorEnabled(NodeConnector nodeConnector) { + val ref = nodeConnector.toNodeConnectorRef + val data = readNodeConnector(ref.value); + + return true; + } + + override isSpecial(NodeConnector p) { + val ref = p.toNodeConnectorRef + val data = readNodeConnector(ref.value); + + return true; + } + + override removeControllerProperty(String propertyName) { + // NOOP + } + + override removeNodeAllProps(Node node) { + // NOOP: not supported node has more properties than AD-SAL is capable to see + } + + override removeNodeConnectorAllProps(NodeConnector nodeConnector) { + // NOOP: not supported node has more properties than AD-SAL is capable to see + } + + override removeNodeConnectorProp(NodeConnector nc, String propName) { + // NOOP: not supported node has more properties than AD-SAL is capable to see + } + + override removeNodeProp(Node node, String propName) { + // NOOP: not supported node has more properties than AD-SAL is capable to see + } + + override removePortsFromSubnet(String name, List nodeConnectors) { + // NOOP + } + + override removeSubnet(String name) { + // NOOP + } + + override setControllerProperty(Property property) { + // NOOP + } + + override setNodeProp(Node node, Property prop) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override addPortsToSubnet(String name, List nodeConnectors) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + } diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend new file mode 100644 index 0000000000..122aa32f12 --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/switchmanager/ConfigurableSwitchManager.xtend @@ -0,0 +1,71 @@ +package org.opendaylight.controller.md.compatibility.switchmanager + +import org.opendaylight.controller.switchmanager.ISwitchManager +import org.opendaylight.controller.switchmanager.SpanConfig +import org.opendaylight.controller.switchmanager.SwitchConfig +import org.opendaylight.controller.switchmanager.SubnetConfig + +/** + * + * THis methods should be backed by config subsystem. + * + */ +abstract class ConfigurableSwitchManager implements ISwitchManager { + + override saveSwitchConfig() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override removeSpanConfig(SpanConfig cfgObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override addSubnet(SubnetConfig configObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + final override addSpanConfig(SpanConfig configObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + final override getSpanConfigList() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + final override updateSwitchConfig(SwitchConfig cfgObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + final override updateNodeConfig(SwitchConfig switchConfig) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + final override getSubnetConfig(String subnet) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + final override removeNodeConfig(String nodeId) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + final override removeSubnet(SubnetConfig configObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + final override getSubnetsConfigList() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + final override getSwitchConfig(String nodeId) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override modifySubnet(SubnetConfig configObject) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend new file mode 100644 index 0000000000..2ae74de108 --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyMapping.xtend @@ -0,0 +1,77 @@ +package org.opendaylight.controller.md.compatibility.topology + +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier +import org.opendaylight.yangtools.yang.binding.DataObject +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology +import org.opendaylight.controller.sal.core.Edge +import java.util.Set +import org.opendaylight.controller.sal.core.Property +import org.opendaylight.controller.sal.core.NodeConnector + +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TpId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NodeId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.LinkKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.LinkId +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node + +class TopologyMapping { + + new(TopologyKey path, InstanceIdentifier key) { + // NOOP + } + + def Edge toAdTopologyEdge(InstanceIdentifier identifier) { + val linkKey = (identifier.path.last as IdentifiableItem).key; + val components = linkKey.linkId.value.split("::::"); + val tail = nodeConnectorFromString(components.get(0).split("::")); + val head = nodeConnectorFromString(components.get(1).split("::")); + return new Edge(tail, head); + } + + def NodeConnector toAdTopologyNodeConnector(InstanceIdentifier identifier) { + val tpKey = (identifier.path.last as IdentifiableItem).key; + return nodeConnectorFromString(tpKey.tpId.value.split("::")); + } + + def org.opendaylight.controller.sal.core.Node toAdTopologyNode( + InstanceIdentifier identifier) { + val tpKey = (identifier.path.last as IdentifiableItem).key; + return nodeFromString(tpKey.nodeId.value.split("::")); + } + + + + def NodeKey toTopologyNodeKey(org.opendaylight.controller.sal.core.Node node) { + val nodeId = new NodeId('''ad-sal:«node.type»::«node.nodeIDString»''') + return new NodeKey(nodeId); + } + + def TerminationPointKey toTopologyTerminationPointKey(NodeConnector nc) { + val node = nc.node; + val nodeId = new TpId('''ad-sal:«node.type»::«node.nodeIDString»::«nc.nodeConnectorIDString»''') + return new TerminationPointKey(nodeId); + } + + def LinkKey toTopologyLinkKey(Edge edge) { + val sourceTp = edge.tailNodeConnector.toTopologyTerminationPointKey; + val destTp = edge.headNodeConnector.toTopologyTerminationPointKey; + val linkId = new LinkId('''«sourceTp.tpId»::::«destTp.tpId»''') + return new LinkKey(linkId); + } + + def NodeConnector nodeConnectorFromString(String[] string) { + val node = nodeFromString(string.subList(0,1)); + return NodeConnector.fromStringNoNode(string.get(2),node); + } + + def org.opendaylight.controller.sal.core.Node nodeFromString(String[] strings) { + val type = strings.get(0).substring(6); + org.opendaylight.controller.sal.core.Node.fromString(type,strings.get(1)) + } +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend new file mode 100644 index 0000000000..fb9d2b8786 --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topology/TopologyReader.xtend @@ -0,0 +1,151 @@ +package org.opendaylight.controller.md.compatibility.topology + +import org.opendaylight.controller.switchmanager.ISwitchManager +import org.opendaylight.controller.topologymanager.ITopologyManager +import org.opendaylight.controller.md.sal.common.api.data.DataReader +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier +import org.opendaylight.yangtools.yang.binding.DataObject +import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NetworkTopology +import org.opendaylight.controller.md.compatibility.topology.TopologyMapping +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.LinkBuilder + +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyBuilder +import java.util.ArrayList +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeBuilder +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.NodeKey +import org.opendaylight.controller.sal.core.NodeConnector +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TopologyId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointBuilder +import org.opendaylight.controller.sal.core.Edge +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.SourceBuilder +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.DestinationBuilder + +class TopologyReader implements RuntimeDataProvider { + + @Property + var ISwitchManager switchManager; + + @Property + var ITopologyManager topologyManager; + + @Property + val TopologyKey topologyKey; + + @Property + val InstanceIdentifier topologyPath; + + @Property + val extension TopologyMapping mapping; + + new() { + _topologyKey = new TopologyKey(new TopologyId("compatibility:ad-sal")); + _topologyPath = InstanceIdentifier.builder().node(NetworkTopology).child(Topology, topologyKey).toInstance; + _mapping = new TopologyMapping(topologyKey, topologyPath); + } + + override readConfigurationData(InstanceIdentifier path) { + + // Topology and Inventory are operational only + return null; + } + + override readOperationalData(InstanceIdentifier path) { + val type = path.targetType; + var DataObject data = null; + if (false == topologyPath.contains(path)) { + return null; + } + switch (type) { + case Topology: + data = readTopology(path as InstanceIdentifier) + case Node: + data = readNode(path as InstanceIdentifier) + case TerminationPoint: + data = readTerminationPoint(path as InstanceIdentifier) + case Link: + data = readLink(path as InstanceIdentifier) + } + return data; + } + + def DataObject readLink(InstanceIdentifier identifier) { + val edge = identifier.toAdTopologyEdge(); + val properties = topologyManager?.edges?.get(edge); + + return constructLink(edge); + } + + def DataObject readTerminationPoint(InstanceIdentifier identifier) { + val nodeConnector = identifier.toAdTopologyNodeConnector(); + return constructTerminationPoint(nodeConnector) + } + + def DataObject readNode(InstanceIdentifier identifier) { + val node = identifier.toAdTopologyNode(); + return constructNode(node); + } + + def DataObject readTopology(InstanceIdentifier identifier) { + + //val nodeConnectors = switchManager. + val nodes = switchManager.nodes + val edges = topologyManager.edges + + val nodeList = new ArrayList(nodes.size) + for (node : nodes) { + nodeList.add(constructNode(node)) + } + + val linkList = new ArrayList(edges.size) + for (edge : edges.keySet) { + linkList.add(constructLink(edge)) + } + + val it = new TopologyBuilder(); + key = topologyKey + node = nodeList + link = linkList + return build() + } + + def constructLink(Edge edge) { + val sourceNc = edge.tailNodeConnector + val destNc = edge.headNodeConnector + + val it = new LinkBuilder() + key = edge.toTopologyLinkKey(); + source = new SourceBuilder().setSourceNode(sourceNc.node.toTopologyNodeKey.nodeId).setSourceTp( + sourceNc.toTopologyTerminationPointKey.tpId).build() + destination = new DestinationBuilder().setDestNode(destNc.node.toTopologyNodeKey.nodeId).setDestTp( + destNc.toTopologyTerminationPointKey.tpId).build + return build() + } + + def Node constructNode(org.opendaylight.controller.sal.core.Node node) { + val connectors = switchManager.getNodeConnectors(node) + + val tpList = new ArrayList(connectors.size) + for (connector : connectors) { + tpList.add(constructTerminationPoint(connector)); + } + + val it = new NodeBuilder() + key = node.toTopologyNodeKey(); + terminationPoint = tpList + return build(); + } + + def TerminationPoint constructTerminationPoint(NodeConnector connector) { + val it = new TerminationPointBuilder() + key = connector.toTopologyTerminationPointKey + return build(); + } + +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend new file mode 100644 index 0000000000..ad7537bc0d --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/AdSalTopologyMapping.xtend @@ -0,0 +1,94 @@ +package org.opendaylight.controller.md.compatibility.topologymanager + +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.TopologyKey +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint +import org.opendaylight.controller.sal.core.NodeConnector +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.Topology +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NetworkTopology +import java.util.Map +import org.opendaylight.controller.sal.core.Edge +import java.util.Set +import java.util.List +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Node +import java.util.Collections +import com.google.common.collect.FluentIterable +import java.util.HashSet +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId +import org.opendaylight.controller.sal.compatibility.NodeMapping +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.Link +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.Source +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.link.attributes.Destination +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.TpId +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPointKey +import java.util.HashMap + +class AdSalTopologyMapping { + + val TopologyKey topologyMapping; + @Property + val InstanceIdentifier topologyPath; + + new(TopologyKey topology) { + topologyMapping = topology; + _topologyPath = InstanceIdentifier.builder.node(NetworkTopology).child(Topology, topology).toInstance; + } + + def InstanceIdentifier toTerminationPoint(NodeConnector connector) { + InstanceIdentifier.builder(topologyPath).node(Node).child(TerminationPoint, connector.toTerminationPointKey()).toInstance; + } + + def Map> toEdgePropertiesMap(Iterable links) { + val ret = new HashMap> + for (link : links) { + ret.put(link.toEdge(), link.toProperties()) + } + return ret; + } + + def Set toEdges(Iterable links) { + val ret = new HashSet + for (link : links) { + ret.add(link.toEdge) + } + return ret; + } + + def Edge toEdge(Link link) { + val tail = link.source.toNodeConnector(); + val head = link.destination.toNodeConnector(); + return new Edge(tail, head); + } + + def org.opendaylight.controller.sal.core.Node toAdNode(Node node) { + return node.nodeId.toAdNode; + } + + def org.opendaylight.controller.sal.core.Node toAdNode( + org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.NodeId node) { + val key = new NodeKey(new NodeId(node)) + return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, key); + } + + def NodeConnector toNodeConnector(Source ref) { + val adNode = ref.sourceNode.toAdNode(); + val key = new NodeConnectorKey(new NodeConnectorId(ref.sourceTp)) + return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode); + } + + def NodeConnector toNodeConnector(Destination ref) { + val adNode = ref.destNode.toAdNode(); + val key = new NodeConnectorKey(new NodeConnectorId(ref.destTp)) + return new NodeConnector(NodeMapping.MD_SAL_TYPE, key, adNode); + } + + def TerminationPointKey toTerminationPointKey(NodeConnector connector) { + } + + def Set toProperties(Link link) { + } +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend new file mode 100644 index 0000000000..c6a4912f2d --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/CompatibleTopologyManager.xtend @@ -0,0 +1,85 @@ +package org.opendaylight.controller.md.compatibility.topologymanager + +import org.opendaylight.controller.topologymanager.ITopologyManager +import org.opendaylight.controller.sal.core.NodeConnector +import org.opendaylight.controller.sal.core.Host +import org.opendaylight.controller.sal.core.UpdateType +import java.util.Set +import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader +import java.util.HashMap +import org.opendaylight.controller.sal.core.Edge +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.network.topology.topology.node.TerminationPoint +import com.google.common.collect.FluentIterable + +class CompatibleTopologyManager extends ConfigurableLinkManager implements ITopologyManager { + + @Property + var TypeSafeDataReader dataReader; + + @Property + var extension AdSalTopologyMapping topologyMapping; + + override getEdges() { + val topology = dataReader.readOperationalData(topologyPath); + return topology.link.toEdgePropertiesMap(); + } + + override getNodeEdges() { + val topology = dataReader.readOperationalData(topologyPath); + val ret = new HashMap>; + for (node : topology.node) { + val adNode = node.toAdNode(); + val adEdges = FluentIterable.from(topology.link).filter[ + source.sourceNode == node.nodeId || destination.destNode == node.nodeId].toEdges(); + ret.put(adNode, adEdges) + } + return ret; + } + + /** + * Returns true if point is connected to link + */ + def isInternal(TerminationPoint point) { + val topology = dataReader.readConfigurationData(topologyPath); + val tpId = point.key.tpId; + return FluentIterable.from(topology.link).anyMatch( + [ + source.sourceTp == tpId || destination.destTp == tpId + ]) + } + + override getNodeConnectorWithHost() { + } + + override getHostAttachedToNodeConnector(NodeConnector p) { + val tpPath = p.toTerminationPoint(); + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override getHostsAttachedToNodeConnector(NodeConnector p) { + val topology = dataReader.readOperationalData(topologyPath); + + throw new UnsupportedOperationException("Hosts not mapped yet") + } + + override getNodesWithNodeConnectorHost() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + override isInternal(NodeConnector p) { + val tpPath = p.toTerminationPoint(); + val connector = dataReader.readConfigurationData(tpPath); + return connector.isInternal(); + } + + override updateHostLink(NodeConnector p, Host h, UpdateType t, + Set props) { + // Update app defined topology + } + + override saveConfig() { + // FIXME: commit configuration + } + +} diff --git a/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend new file mode 100644 index 0000000000..da3bf66424 --- /dev/null +++ b/opendaylight/md-sal/compatibility/inventory-topology-compatibility/src/main/java/org/opendaylight/controller/md/compatibility/topologymanager/ConfigurableLinkManager.xtend @@ -0,0 +1,24 @@ +package org.opendaylight.controller.md.compatibility.topologymanager + +import org.opendaylight.controller.topologymanager.ITopologyManager +import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig + +abstract class ConfigurableLinkManager implements ITopologyManager { + + final override addUserLink(TopologyUserLinkConfig link) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + + final override deleteUserLink(String linkName) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } + + + final override getUserLinks() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/compatibility/pom.xml b/opendaylight/md-sal/compatibility/pom.xml new file mode 100644 index 0000000000..a829380e68 --- /dev/null +++ b/opendaylight/md-sal/compatibility/pom.xml @@ -0,0 +1,101 @@ + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.0-SNAPSHOT + + compatibility-parent + pom + MD-SAL to AD-SAL Adaptation + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + + + sal-compatibility + inventory-topology-compatibility + flow-management-compatibility + + + + + org.opendaylight.controller + sal + 0.5.1-SNAPSHOT + + + org.opendaylight.controller.model + model-flow-service + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-common-util + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-binding-api + 1.0-SNAPSHOT + + + com.google.guava + guava + + + org.eclipse.xtend + org.eclipse.xtend.lib + + + junit + junit + test + + + + + + + org.eclipse.xtend + xtend-maven-plugin + + + org.apache.felix + maven-bundle-plugin + + + ${project.name} + org.opendaylight.controller.sal.compability.ComponentActivator + + + + + org.jacoco + jacoco-maven-plugin + + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + test + + report + + + + + + + + diff --git a/opendaylight/md-sal/sal-compability/pom.xml b/opendaylight/md-sal/compatibility/sal-compatibility/pom.xml similarity index 65% rename from opendaylight/md-sal/sal-compability/pom.xml rename to opendaylight/md-sal/compatibility/sal-compatibility/pom.xml index 6d992de015..15a9a689b3 100644 --- a/opendaylight/md-sal/sal-compability/pom.xml +++ b/opendaylight/md-sal/compatibility/sal-compatibility/pom.xml @@ -3,10 +3,10 @@ 4.0.0 org.opendaylight.controller - sal-parent + compatibility-parent 1.0-SNAPSHOT - sal-compability + sal-compatibility MD-SAL to AD-SAL Adaptation scm:git:ssh://git.opendaylight.org:29418/controller.git @@ -15,44 +15,11 @@ - - org.opendaylight.controller - sal - 0.5.1-SNAPSHOT - - - org.opendaylight.controller.model - model-flow-service - 1.0-SNAPSHOT - org.opendaylight.controller.model model-flow-statistics 1.0-SNAPSHOT - - org.opendaylight.controller - sal-common-util - 1.0-SNAPSHOT - - - org.opendaylight.controller - sal-binding-api - 1.0-SNAPSHOT - - - com.google.guava - guava - - - org.eclipse.xtend - org.eclipse.xtend.lib - - - junit - junit - test - bundle @@ -68,7 +35,7 @@ ${project.name} - org.opendaylight.controller.sal.compability.ComponentActivator + org.opendaylight.controller.sal.compatibility.ComponentActivator diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ComponentActivator.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend similarity index 97% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ComponentActivator.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend index 5c1723ec7e..b460edff74 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ComponentActivator.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend @@ -1,10 +1,10 @@ -package org.opendaylight.controller.sal.compability +package org.opendaylight.controller.sal.compatibility import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey import org.opendaylight.controller.sal.core.Node import org.opendaylight.controller.sal.core.NodeConnector -import static org.opendaylight.controller.sal.compability.NodeMapping.* +import static org.opendaylight.controller.sal.compatibility.NodeMapping.* import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey import org.apache.felix.dm.Component import java.util.Arrays diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/DataPacketAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/DataPacketAdapter.xtend similarity index 93% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/DataPacketAdapter.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/DataPacketAdapter.xtend index 422599c62b..ce6af6469e 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/DataPacketAdapter.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/DataPacketAdapter.xtend @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability +package org.opendaylight.controller.sal.compatibility import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FlowProgrammerAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.xtend similarity index 93% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FlowProgrammerAdapter.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.xtend index 385007b375..da652e65a7 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FlowProgrammerAdapter.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.xtend @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability +package org.opendaylight.controller.sal.compatibility import java.util.concurrent.ExecutionException import org.opendaylight.controller.sal.core.Node @@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF import org.opendaylight.yangtools.yang.common.RpcResult import org.slf4j.LoggerFactory -import static org.opendaylight.controller.sal.compability.MDFlowMapping.* +import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.* -import static extension org.opendaylight.controller.sal.compability.NodeMapping.* -import static extension org.opendaylight.controller.sal.compability.ToSalConversionsUtils.* +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* +import static extension org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.* class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, SalFlowListener { diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java index 8b8668999e..a31d8e265d 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/FromSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability; +package org.opendaylight.controller.sal.compatibility; import static org.opendaylight.controller.sal.match.MatchType.DL_DST; import static org.opendaylight.controller.sal.match.MatchType.DL_SRC; @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.opendaylight.controller.sal.compatibility.MDFlowMapping; import org.opendaylight.controller.sal.core.NodeConnector; @@ -25,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; - import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.Address; @@ -57,18 +57,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; - import com.google.common.net.InetAddresses; - - - - - - - - -import static org.opendaylight.controller.sal.compability.ProtocolConstants.*; -import static org.opendaylight.controller.sal.compability.NodeMapping.*; +import static org.opendaylight.controller.sal.compatibility.NodeMapping.*; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.*; public class FromSalConversionsUtils { diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/InventoryAndReadAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/InventoryAndReadAdapter.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend index c9c60e2141..8ac6f1b050 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/InventoryAndReadAdapter.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability +package org.opendaylight.controller.sal.compatibility import org.opendaylight.controller.sal.reader.IPluginInReadService import org.opendaylight.controller.sal.core.NodeConnector @@ -8,8 +8,8 @@ import org.opendaylight.controller.sal.core.NodeTable import org.opendaylight.controller.sal.binding.api.data.DataBrokerService import static extension org.opendaylight.controller.sal.common.util.Arguments.* -import static extension org.opendaylight.controller.sal.compability.NodeMapping.* -import static org.opendaylight.controller.sal.compability.MDFlowMapping.* +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* +import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.* import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend index cd03df8398..b43e8af661 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability; +package org.opendaylight.controller.sal.compatibility; import com.google.common.net.InetAddresses import java.math.BigInteger @@ -73,8 +73,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherTyp import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp -import static extension org.opendaylight.controller.sal.compability.FromSalConversionsUtils.* -import static extension org.opendaylight.controller.sal.compability.NodeMapping.* +import static extension org.opendaylight.controller.sal.compatibility.FromSalConversionsUtils.* +import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeMapping.xtend rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend index 2a771def12..b180d86c32 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/NodeMapping.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.xtend @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability +package org.opendaylight.controller.sal.compatibility import org.opendaylight.controller.sal.core.Node import org.opendaylight.controller.sal.core.NodeConnector diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ProtocolConstants.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ProtocolConstants.java similarity index 88% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ProtocolConstants.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ProtocolConstants.java index 1828dac464..7392f5c763 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ProtocolConstants.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ProtocolConstants.java @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability; +package org.opendaylight.controller.sal.compatibility; public class ProtocolConstants { // source: http://en.wikipedia.org/wiki/Ethertype diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java index 41b425ef2d..5009e5dfb7 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java @@ -1,6 +1,7 @@ -package org.opendaylight.controller.sal.compability; +package org.opendaylight.controller.sal.compatibility; import com.google.common.net.InetAddresses; + import org.opendaylight.controller.sal.action.Controller; import org.opendaylight.controller.sal.action.Drop; import org.opendaylight.controller.sal.action.Flood; @@ -91,10 +92,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.ETHERNET_ARP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.SCTP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.TCP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.UDP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.SCTP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP; import static org.opendaylight.controller.sal.match.MatchType.DL_DST; import static org.opendaylight.controller.sal.match.MatchType.DL_SRC; import static org.opendaylight.controller.sal.match.MatchType.DL_TYPE; diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/DataPacketServiceAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/DataPacketServiceAdapter.java similarity index 92% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/DataPacketServiceAdapter.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/DataPacketServiceAdapter.java index 8efa17340d..aa67600124 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/DataPacketServiceAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/DataPacketServiceAdapter.java @@ -1,6 +1,6 @@ -package org.opendaylight.controller.sal.compability.adsal; +package org.opendaylight.controller.sal.compatibility.adsal; -import org.opendaylight.controller.sal.compability.NodeMapping; +import org.opendaylight.controller.sal.compatibility.NodeMapping; import org.opendaylight.controller.sal.packet.IPluginInDataPacketService; import org.opendaylight.controller.sal.packet.RawPacket; import org.opendaylight.controller.sal.packet.RawPacket; diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowServiceAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java similarity index 94% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowServiceAdapter.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java index 809ad76e5a..6267c048a6 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowServiceAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java @@ -1,12 +1,12 @@ -package org.opendaylight.controller.sal.compability.adsal; +package org.opendaylight.controller.sal.compatibility.adsal; import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.common.util.Futures; import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.compability.NodeMapping; -import org.opendaylight.controller.sal.compability.ToSalConversionsUtils; +import org.opendaylight.controller.sal.compatibility.NodeMapping; +import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.flowprogrammer.Flow; diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowStatisticsAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java similarity index 98% rename from opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowStatisticsAdapter.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java index 3963aacd03..f5c5620d7c 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/adsal/FlowStatisticsAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java @@ -1,4 +1,4 @@ -package org.opendaylight.controller.sal.compability.adsal; +package org.opendaylight.controller.sal.compatibility.adsal; import java.math.BigInteger; import java.util.ArrayList; @@ -8,8 +8,8 @@ import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.common.util.Futures; import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.compability.NodeMapping; -import org.opendaylight.controller.sal.compability.ToSalConversionsUtils; +import org.opendaylight.controller.sal.compatibility.NodeMapping; +import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.flowprogrammer.Flow; diff --git a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java similarity index 85% rename from opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java index e6d05553ef..1c8b772d72 100644 --- a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java @@ -3,58 +3,23 @@ package org.opendaylight.controller.sal.compability; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.ETHERNET_ARP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.SCTP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.TCP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.UDP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.SCTP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP; import java.util.ArrayList; import java.util.List; import org.junit.Test; -import org.opendaylight.controller.sal.action.Action; -import org.opendaylight.controller.sal.action.Flood; -import org.opendaylight.controller.sal.action.FloodAll; -import org.opendaylight.controller.sal.action.HwPath; -import org.opendaylight.controller.sal.action.Loopback; -import org.opendaylight.controller.sal.action.PopVlan; -import org.opendaylight.controller.sal.action.PushVlan; -import org.opendaylight.controller.sal.action.SetDlDst; -import org.opendaylight.controller.sal.action.SetDlSrc; -import org.opendaylight.controller.sal.action.SetDlType; -import org.opendaylight.controller.sal.action.SetNextHop; -import org.opendaylight.controller.sal.action.SetNwDst; -import org.opendaylight.controller.sal.action.SetNwSrc; -import org.opendaylight.controller.sal.action.SetNwTos; -import org.opendaylight.controller.sal.action.SetTpDst; -import org.opendaylight.controller.sal.action.SetTpSrc; -import org.opendaylight.controller.sal.action.SetVlanCfi; -import org.opendaylight.controller.sal.action.SetVlanId; -import org.opendaylight.controller.sal.action.SetVlanPcp; -import org.opendaylight.controller.sal.action.SwPath; +import org.opendaylight.controller.sal.action.*; +import org.opendaylight.controller.sal.compatibility.MDFlowMapping; +import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAllAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.HwPathAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.LoopbackAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PopVlanAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushVlanAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlDstAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlSrcAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlTypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNextHopAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwDstAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwSrcAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpDstAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpSrcAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanCfiAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SwPathAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.*; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv4; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match; diff --git a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java similarity index 82% rename from opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestToSalConversionsUtils.java rename to opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java index 615eca0a67..2b344c0c80 100644 --- a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java @@ -1,77 +1,36 @@ package org.opendaylight.controller.sal.compability; -import com.google.common.net.InetAddresses; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.math.BigInteger; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.junit.Test; -import org.opendaylight.controller.sal.action.Flood; -import org.opendaylight.controller.sal.action.FloodAll; -import org.opendaylight.controller.sal.action.HwPath; -import org.opendaylight.controller.sal.action.Loopback; -import org.opendaylight.controller.sal.action.Output; -import org.opendaylight.controller.sal.action.PopVlan; -import org.opendaylight.controller.sal.action.PushVlan; -import org.opendaylight.controller.sal.action.SetDlDst; -import org.opendaylight.controller.sal.action.SetDlSrc; -import org.opendaylight.controller.sal.action.SetDlType; -import org.opendaylight.controller.sal.action.SetNextHop; -import org.opendaylight.controller.sal.action.SetNwDst; -import org.opendaylight.controller.sal.action.SetNwSrc; -import org.opendaylight.controller.sal.action.SetNwTos; -import org.opendaylight.controller.sal.action.SetTpDst; -import org.opendaylight.controller.sal.action.SetTpSrc; -import org.opendaylight.controller.sal.action.SetVlanCfi; -import org.opendaylight.controller.sal.action.SetVlanId; -import org.opendaylight.controller.sal.action.SetVlanPcp; -import org.opendaylight.controller.sal.action.SwPath; +import org.opendaylight.controller.sal.action.*; +import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.MatchType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.*; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.VlanCfi; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.ControllerActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.DropActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAllActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.HwPathActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.LoopbackActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.OutputActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PopMplsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PopVlanActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushMplsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushPbbActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushVlanActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlDstActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlSrcActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlTypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetMplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNextHopActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwDstActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwSrcActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetQueueActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpDstActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpSrcActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanCfiActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SwPathActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.*; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv4Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions; 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.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.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder; 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.l2.types.rev130827.EtherType; @@ -79,20 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination; -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.EthernetSource; -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.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.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.Layer3Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.*; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.*; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder; 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.Ipv6MatchBuilder; @@ -100,21 +47,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder; -import java.math.BigInteger; -import java.net.Inet4Address; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import com.google.common.net.InetAddresses; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.ETHERNET_ARP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.SCTP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.TCP; -import static org.opendaylight.controller.sal.compability.ProtocolConstants.UDP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.SCTP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP; +import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP; public class TestToSalConversionsUtils { // prefix: diff --git a/opendaylight/md-sal/model/model-topology/pom.xml b/opendaylight/md-sal/model/model-topology/pom.xml new file mode 100644 index 0000000000..c91b9dd53a --- /dev/null +++ b/opendaylight/md-sal/model/model-topology/pom.xml @@ -0,0 +1,31 @@ + + + + model-parent + org.opendaylight.controller.model + 1.0-SNAPSHOT + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + + 4.0.0 + model-topology + bundle + + + + org.opendaylight.controller.model + model-inventory + 1.0-SNAPSHOT + + + org.opendaylight.yangtools.model + ietf-topology + 2013.07.12.2-SNAPSHOT + + + diff --git a/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology-inventory.yang b/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology-inventory.yang new file mode 100644 index 0000000000..33c03ba059 --- /dev/null +++ b/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology-inventory.yang @@ -0,0 +1,34 @@ +module opendaylight-topology-inventory { + yang-version 1; + namespace "urn:opendaylight:model:topology:inventory"; + // replace with IANA namespace when assigned + prefix "nt"; + + import yang-ext { prefix "ext"; } + import ietf-inet-types { prefix "inet"; } + import opendaylight-inventory {prefix "inv";} + import opendaylight-topology {prefix "odt";} + import network-topology {prefix "topo";} + + organization "TBD"; + + contact "WILL-BE-DEFINED-LATER"; + + revision 2013-10-30 { + description + "Initial revision."; + } + + augment "/topo:network-topology/topo:topology/topo:node" { + ext:augment-identifier "inventory-node"; + uses inv:node-context-ref; + } + + augment "/topo:network-topology/topo:topology/topo:node/topo:termination-point" { + ext:augment-identifier "inventory-node-connector"; + leaf node-connector { + ext:context-reference "inv:node-connector-context"; + type inv:node-connector-ref; + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology.yang b/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology.yang new file mode 100644 index 0000000000..038a1b7c67 --- /dev/null +++ b/opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology.yang @@ -0,0 +1,64 @@ +module opendaylight-topology { + yang-version 1; + namespace "urn:opendaylight:model:topology:general"; + // replace with IANA namespace when assigned + prefix "nt"; + + import yang-ext { prefix "ext"; } + import ietf-inet-types { prefix "inet"; } + import opendaylight-inventory {prefix "inv";} + import network-topology {prefix "topo";} + + organization "TBD"; + + contact "WILL-BE-DEFINED-LATER"; + + revision 2013-10-30 { + description + "Initial revision."; + } + + identity node-type { + + } + + typedef node-type-ref { + type identityref { + base node-type; + } + } + + identity topology-context { + + } + + identity topology-node-context { + + } + + grouping node-identifiers { + list node-identifier { + key "type identifier"; + leaf type { + type node-type-ref; + } + leaf identifier { + type inet:uri; + } + } + } + + augment "/topo:network-topology/topo:topology" { + ext:context-instance "topology-context"; + } + + /* Inventory Augmentations */ + augment "/topo:network-topology/topo:topology/topo:node" { + ext:context-instance "topology-node-context"; + } + + augment "/topo:network-topology/topo:topology/topo:node" { + ext:augment-identifier "identifiable-node"; + uses node-identifiers; + } +} diff --git a/opendaylight/md-sal/model/model-topology/src/main/yang/topology-view.yang b/opendaylight/md-sal/model/model-topology/src/main/yang/topology-view.yang new file mode 100644 index 0000000000..2fecb327ca --- /dev/null +++ b/opendaylight/md-sal/model/model-topology/src/main/yang/topology-view.yang @@ -0,0 +1,48 @@ +module opendaylight-topology-view { + yang-version 1; + namespace "urn:opendaylight:model:topology:view"; + // replace with IANA namespace when assigned + prefix "nt"; + + import yang-ext { prefix "ext"; } + import ietf-inet-types { prefix "inet"; } + import network-topology {prefix "topo";} + import opendaylight-topology {prefix "odl";} + + organization "TBD"; + + contact "WILL-BE-DEFINED-LATER"; + + revision 2013-10-30 { + description + "Initial revision."; + } + + + grouping aggregate-topology { + leaf-list original-topology { + type topo:topology-ref; + } + } + + grouping aggregate-node { + list original-node { + leaf topology { + type topo:topology-ref; + } + leaf node { + type topo:node-ref; + } + } + } + + augment "/topo:network-topology/topo:topology" { + ext:augment-identifier "aggregated-topology"; + uses aggregate-topology; + } + + augment "/topo:network-topology/topo:topology/topo:node" { + ext:augment-identifier "aggregated-node"; + uses aggregate-node; + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/model/pom.xml b/opendaylight/md-sal/model/pom.xml index ca97232cfb..eccb691fa7 100644 --- a/opendaylight/md-sal/model/pom.xml +++ b/opendaylight/md-sal/model/pom.xml @@ -28,6 +28,7 @@ model-flow-service model-flow-statistics model-flow-management + model-topology diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 06df83ec7f..fd89da4dd0 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -28,23 +28,26 @@ sal-binding-config sal-binding-broker + sal-binding-util + samples model - - sal-compability sal-connector-api sal-rest-connector - flow-management-compatibility clustered-data-store/implementation + inventory-manager + + compatibility + sal-zeromq-connector test diff --git a/opendaylight/md-sal/sal-binding-util/pom.xml b/opendaylight/md-sal/sal-binding-util/pom.xml new file mode 100644 index 0000000000..26041ea85e --- /dev/null +++ b/opendaylight/md-sal/sal-binding-util/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.0-SNAPSHOT + + sal-binding-util + bundle + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + + + + com.google.guava + guava + + + org.opendaylight.controller + sal-binding-api + 1.0-SNAPSHOT + + + org.apache.felix + org.apache.felix.dependencymanager + 3.1.0 + + + diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java new file mode 100644 index 0000000000..738a14a9bd --- /dev/null +++ b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/TypeSafeDataReader.java @@ -0,0 +1,38 @@ +package org.opendaylight.controller.md.sal.binding.util; + +import org.opendaylight.controller.md.sal.common.api.data.DataReader; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public final class TypeSafeDataReader { + + + private final DataReader,DataObject> delegate; + + + + public DataReader, DataObject> getDelegate() { + return delegate; + } + + + public TypeSafeDataReader(DataReader, DataObject> delegate) { + this.delegate = delegate; + } + + + @SuppressWarnings("unchecked") + public D readConfigurationData(InstanceIdentifier path) { + return (D) delegate.readConfigurationData(path); + } + + + @SuppressWarnings("unchecked") + public D readOperationalData(InstanceIdentifier path) { + return (D) delegate.readOperationalData(path); + } + + public static TypeSafeDataReader forReader(DataReader, DataObject> delegate) { + return new TypeSafeDataReader(delegate); + } +} diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java new file mode 100644 index 0000000000..08df0a414a --- /dev/null +++ b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/ToSalPropertyClassUtils.java @@ -0,0 +1,70 @@ +package org.opendaylight.controller.sal.compability; + +import org.opendaylight.controller.sal.core.*; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; + +public class ToSalPropertyClassUtils { + public static Bandwidth salAdvertisedBandwidthFrom(NodeConnector nodeConnector) { + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + PortFeatures portFeatures = flowCapNodeConn.getAdvertisedFeatures(); + return new AdvertisedBandwidth(resolveBandwidth(portFeatures)); + } + + public static Bandwidth salPeerBandwidthFrom(NodeConnector nodeConnector) { + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + PortFeatures portFeatures = flowCapNodeConn.getPeerFeatures(); + return new PeerBandwidth(resolveBandwidth(portFeatures)); + } + + public static Bandwidth salSupportedBandwidthFrom(NodeConnector nodeConnector) { + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + PortFeatures portFeatures = flowCapNodeConn.getSupported(); + return new SupportedBandwidth(resolveBandwidth(portFeatures)); + } + + public static MacAddress salMacAddressFrom(NodeConnector nodeConnector) { + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + String hwAddress = flowCapNodeConn.getHardwareAddress().getValue(); + return new MacAddress(bytesFrom(hwAddress)); + } + + + public static Name salNameFrom(NodeConnector nodeConnector) { + FlowCapableNodeConnector flowCapNodeConn = nodeConnector.getAugmentation(FlowCapableNodeConnector.class); + return new Name(flowCapNodeConn.getName()); + } + + + + private static byte[] bytesFrom(String hwAddress) { + String[] mac = hwAddress.split(":"); + byte[] macAddress = new byte[6]; // mac.length == 6 bytes + for (int i = 0; i < mac.length; i++) { + macAddress[i] = Integer.decode("0x" + mac[i]).byteValue(); + } + return macAddress; + } + + private static long resolveBandwidth(PortFeatures portFeatures) { + if (portFeatures.is_1tbFd()) { + return Bandwidth.BW1Tbps; + } else if (portFeatures.is_100gbFd()) { + return Bandwidth.BW100Gbps; + } else if (portFeatures.is_40gbFd()) { + return Bandwidth.BW40Gbps; + } else if (portFeatures.is_10gbFd()) { + return Bandwidth.BW10Gbps; + } else if (portFeatures.is_1gbHd() || portFeatures.is_1gbFd()) { + return Bandwidth.BW1Gbps; + } else if (portFeatures.is_100mbHd() || portFeatures.is_100mbFd()) { + return Bandwidth.BW100Mbps; + } else if (portFeatures.is_10mbHd() || portFeatures.is_10mbFd()) { + return Bandwidth.BW10Mbps; + } else { + return Bandwidth.BWUNK; + } + } + +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java index c32e350509..b4cf6c985b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/TestUtils.java @@ -45,7 +45,9 @@ final class TestUtils { } for (int i = 0; i < fileList.length; i++) { String fileName = fileList[i]; - testFiles.add(new File(testDir, fileName)); + if (new File(testDir, fileName).isDirectory() == false) { + testFiles.add(new File(testDir, fileName)); + } } return parser.parseYangModels(testFiles); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlToJsonConversion.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlToJsonConversion.java new file mode 100644 index 0000000000..841f8e593a --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/YangAndXmlToJsonConversion.java @@ -0,0 +1,273 @@ +package org.opendaylight.controller.sal.restconf.impl.test; + +import static org.junit.Assert.*; + +import java.io.*; +import java.util.Set; +import java.util.regex.*; + +import javax.ws.rs.WebApplicationException; + +import org.junit.*; +import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider; +import org.opendaylight.controller.sal.restconf.impl.StructuredData; +import org.opendaylight.yangtools.yang.model.api.*; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; + +public class YangAndXmlToJsonConversion { + + @Ignore + @Test + /** + * Test for simple yang types (leaf, list, leaf-list, container and various combination of them) + * + */ + public void simpleYangTypesTest() { + String jsonOutput = null; + + jsonOutput = convertXmlDataAndYangToJson("/yang-to-json-conversion/simple-yang-types/xml/data.xml", + "/yang-to-json-conversion/simple-yang-types"); + +// jsonOutput = +// readJsonFromFile("/yang-to-json-conversion/simple-yang-types/xml/output.json"); + + verifyJsonOutputForSimpleYangTypes(jsonOutput); + + } + + private void verifyJsonOutputForSimpleYangTypes(String jsonOutput) { + + assertTrue("First and last character has to be '{' and '}'", Pattern.compile("\\A\\{.*\\}\\z", Pattern.DOTALL) + .matcher(jsonOutput).matches()); + + String prefix = "\"(smptp:|)"; + + // subnodes of cont1 + String cont1 = prefix + "cont1\":\\{"; + testLeaf(cont1, "lf11", new String("lf"), jsonOutput, prefix); + testLeafList(cont1, "lflst11", jsonOutput, prefix, new Integer(55), new Integer(56), new Integer(57)); + testLeafList(cont1, "lflst12", jsonOutput, prefix, new String("lflst12 str1"), new String("lflst12 str2"), + new String("lflst12 str1")); + + // subnodes of lst111 + // first object of lst111 + String lst11 = cont1 + ".*" + prefix + "lst11\":\\[\\{"; + testLeaf(lst11, "lf111", new Integer(140), jsonOutput, prefix); + testLeaf(lst11, "lf112", new String("lf112 str"), jsonOutput, prefix); + + // subnodes of cont111 + String cont111 = lst11 + ".*" + prefix + "cont111\":\\{"; + testLeaf(cont111, "lf1111", new String("lf1111 str"), jsonOutput, prefix); + testLeafList(cont1, "lflst1111", jsonOutput, prefix, new Integer(2048), new Integer(1024), new Integer(4096)); + + // subnodes of lst1111 + String lst1111 = cont111 + ".*" + prefix + "lst1111\":\\[\\{"; + testLeaf(lst1111, "lf1111A", new String("lf1111A str11"), jsonOutput, prefix); + testLeaf(lst1111, "lf1111B", new Integer(4), jsonOutput, prefix); + testLeaf(lst1111, "lf1111A", new String("lf1111A str12"), jsonOutput, prefix); + testLeaf(lst1111, "lf1111B", new Integer(7), jsonOutput, prefix); + // :subnodes of lst1111 + // :subnodes of cont111 + // :first object of lst111 + + // second object of lst111 + testLeaf(lst11, "lf111", new Integer(141), jsonOutput, prefix); + testLeaf(lst11, "lf112", new String("lf112 str2"), jsonOutput, prefix); + + // subnodes of cont111 + testLeaf(cont111, "lf1111", new String("lf1111 str2"), jsonOutput, prefix); + testLeafList(cont1, "lflst1111", jsonOutput, prefix, new Integer(2049), new Integer(1025), new Integer(4097)); + + // subnodes of lst1111 + testLeaf(lst1111, "lf1111A", new String("lf1111A str21"), jsonOutput, prefix); + testLeaf(lst1111, "lf1111B", new Integer(5), jsonOutput, prefix); + testLeaf(lst1111, "lf1111A", new String("lf1111A str22"), jsonOutput, prefix); + testLeaf(lst1111, "lf1111B", new Integer(8), jsonOutput, prefix); + // :subnodes of lst111 + // :subnodes of cont111 + // :second object of lst111 + // :second object of lst111 + // :subnodes of cont1 + } + + private void testLeaf(String prevRegEx, String lstName, Object value, String jsonFile, String elementPrefix) { + String newValue = null; + if (value instanceof Integer) { + newValue = value.toString(); + } else if (value instanceof String) { + newValue = "\"" + value.toString() + "\""; + } + String lf = elementPrefix + lstName + "\":" + newValue; + assertTrue(">>\"" + lstName + "\":" + newValue + "<< is missing", + Pattern.compile(".*" + prevRegEx + ".*" + lf + ".*", Pattern.DOTALL).matcher(jsonFile).matches()); + + } + + private void testLeafList(String prevRegEx, String lflstName, String jsonFile, String elementPrefix, + Object... dataInList) { + // order of element in the list isn't defined :( + String lflstBegin = elementPrefix + lflstName + "\":\\["; + String lflstEnd = ".*\\],"; + assertTrue( + ">>\"" + lflstName + "\": [],<< is missing", + Pattern.compile(".*" + prevRegEx + ".*" + lflstBegin + lflstEnd + ".*", Pattern.DOTALL) + .matcher(jsonFile).matches()); + + for (Object obj : dataInList) { + testValueOfLeafList(prevRegEx, lflstBegin, obj, jsonFile); + } + } + + private void testValueOfLeafList(String prevRegEx, String lflstPrevRegEx, Object value, String jsonFile) { + String lflstData = null; + lflstData = regExForDataValueInList(value); + assertNotNull(lflstPrevRegEx + ": value doesn't have correct type.", lflstData); + assertTrue( + prevRegEx + ": data value >" + value + "< is missing.", + Pattern.compile(".*" + prevRegEx + ".*" + lflstPrevRegEx + lflstData + ".*", Pattern.DOTALL) + .matcher(jsonFile).matches()); + + } + + /** + * Data value can be first, inner, last or only one member of list + * + * @param dataValue + * @return + */ + private String regExForDataValueInList(Object dataValue) { + String newDataValue; + if (dataValue instanceof Integer) { + newDataValue = dataValue.toString(); + return "(" + newDataValue + "(,[0-9]+)+|([0-9]+,)+" + newDataValue + "(,[0-9]+)+|([0-9]+,)+" + newDataValue + + "|" + newDataValue + ")\\]"; + } else if (dataValue instanceof String) { + newDataValue = "\"" + dataValue.toString() + "\""; + return "(" + newDataValue + "(,\".+\")+|(\".+\",)+" + newDataValue + "(,\".+\")+|(\".+\",)+" + newDataValue + + "|" + newDataValue + ")\\]"; + } + return null; + } + + private String readJsonFromFile(String path) { + String fullPath = YangAndXmlToJsonConversion.class.getResource(path).getPath(); + assertNotNull("Path to file can't be null.", fullPath); + File file = new File(fullPath); + assertNotNull("File can't be null", file); + FileReader fileReader = null; + try { + fileReader = new FileReader(file); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + assertNotNull("File reader can't be null.", fileReader); + + StringBuilder strBuilder = new StringBuilder(); + char[] buffer = new char[1000]; + + while (true) { + int loadedCharNum; + try { + loadedCharNum = fileReader.read(buffer); + } catch (IOException e) { + break; + } + if (loadedCharNum == -1) { + break; + } + strBuilder.append(buffer, 0, loadedCharNum); + } + try { + fileReader.close(); + } catch (IOException e) { + System.out.println("The file wasn't closed"); + ; + } + String rawStr = strBuilder.toString(); + rawStr = rawStr.replace("\n", ""); + rawStr = rawStr.replace("\r", ""); + rawStr = rawStr.replace("\t", ""); + rawStr = removeSpaces(rawStr); + + return rawStr; + } + + private String removeSpaces(String rawStr) { + StringBuilder strBuilder = new StringBuilder(); + int i = 0; + int quoteCount = 0; + while (i < rawStr.length()) { + if (rawStr.substring(i, i + 1).equals("\"")) { + quoteCount++; + } + + if (!rawStr.substring(i, i + 1).equals(" ") || (quoteCount % 2 == 1)) { + strBuilder.append(rawStr.charAt(i)); + } + i++; + } + + return strBuilder.toString(); + } + + private String convertXmlDataAndYangToJson(String xmlDataPath, String yangPath) { + String jsonResult = null; + Set modules = null; + + try { + modules = TestUtils.loadModules(YangAndXmlToJsonConversion.class.getResource(yangPath).getPath()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + assertNotNull("modules can't be null.", modules); + + InputStream xmlStream = YangAndXmlToJsonConversion.class.getResourceAsStream(xmlDataPath); + CompositeNode compositeNode = null; + try { + compositeNode = TestUtils.loadCompositeNode(xmlStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + assertNotNull("Composite node can't be null", compositeNode); + + StructuredDataToJsonProvider structuredDataToJsonProvider = StructuredDataToJsonProvider.INSTANCE; + for (Module module : modules) { + for (DataSchemaNode dataSchemaNode : module.getChildNodes()) { + StructuredData structuredData = new StructuredData(compositeNode, dataSchemaNode); + ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream(); + try { + structuredDataToJsonProvider.writeTo(structuredData, null, null, null, null, null, byteArrayOS); + } catch (WebApplicationException | IOException e) { + e.printStackTrace(); + } + assertFalse( + "Returning JSON string can't be empty for node " + dataSchemaNode.getQName().getLocalName(), + byteArrayOS.toString().isEmpty()); + jsonResult = byteArrayOS.toString(); + try { + outputToFile(byteArrayOS); + } catch (IOException e) { + System.out.println("Output file wasn't cloased sucessfuly."); + } + } + } + return jsonResult; + } + + private void outputToFile(ByteArrayOutputStream outputStream) throws IOException { + FileOutputStream fileOS = null; + try { + String path = YangAndXmlToJsonConversion.class.getResource("/yang-to-json-conversion/xml").getPath(); + File outFile = new File(path + "/data.json"); + fileOS = new FileOutputStream(outFile); + try { + fileOS.write(outputStream.toByteArray()); + } catch (IOException e) { + e.printStackTrace(); + } + fileOS.close(); + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/simple-yang-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/simple-yang-types.yang new file mode 100644 index 0000000000..760dbd73ed --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/simple-yang-types.yang @@ -0,0 +1,47 @@ +module simple-yang-types { + namespace "simple:yang:types"; + + prefix "smptp"; + revision 2013-11-5 { + description "Initial revision."; + } + + container cont1 { + leaf lf11 { + type string; + } + leaf-list lflst11 { + type int32; + } + leaf-list lflst12 { + type string; + } + list lst11 { + key lf111; + leaf lf111 { + type uint8; + } + leaf lf112 { + type string; + } + container cont111 { + leaf lf1111 { + type string; + } + leaf-list lflst1111 { + type int32; + } + list lst1111 { + leaf lf1111A { + type string; + } + leaf lf1111B { + type uint8; + } + } + } + } + + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/awaited_output.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/awaited_output.json new file mode 100644 index 0000000000..e76e7bd9ef --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/awaited_output.json @@ -0,0 +1,45 @@ +{ + "smptp:cont1": { + "lf11":"lf", + "lflst11": [55,56,57], + "lflst12": ["lflst12 str1", "lflst12 str2", "lflst12 str3"], + "lst11": [ + { + "lf111":140, + "lf112":"lf112 str", + "cont111": { + "lf1111":"lf1111 str", + "lflst1111": [2048, 1024, 4096], + "lst1111": [ + { + "lf1111A": "lf1111A str11", + "lf1111B": 4 + }, + { + "lf1111A": "lf1111A str12", + "lf1111B": 7 + } + ] + } + }, + { + "lf111":141, + "lf112":"lf112 str2", + "cont111": { + "lf1111":"lf1111 str2", + "lflst1111": [2049, 1025, 4097], + "lst1111": [ + { + "lf1111A": "lf1111A str21", + "lf1111B": 5 + }, + { + "lf1111A": "lf1111A str22", + "lf1111B": 8 + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/data.xml new file mode 100644 index 0000000000..b47987ca23 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/yang-to-json-conversion/simple-yang-types/xml/data.xml @@ -0,0 +1,45 @@ + + lf + 55 + 56 + 57 + lflst12 str1 + lflst12 str2 + lflst12 str3 + + 140 + lf112 str + + lf1111 str + 2048 + 1024 + 4096 + + lf1111A str11 + 4 + + + lf1111A str12 + 7 + + + + + 141 + lf112 str2 + + lf1111 str2 + 2049 + 1025 + 4097 + + lf1111A str21 + 5 + + + lf1111A str22 + 8 + + + + diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java index 18c8ce5d15..123c03e9a1 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java @@ -67,6 +67,8 @@ public class EditConfigTest { doNothing().when(provider).abortTestTransaction(any(ObjectName.class)); doReturn(mockOn).when(provider).getOrCreateTransaction(); + doNothing().when(provider).wipeTestTransaction(any(ObjectName.class)); + doReturn(configTransactionClient).when(configRegistry).getConfigTransactionClient(any(ObjectName.class)); doReturn("mockConfigTransactionClient").when(configTransactionClient).toString(); diff --git a/opendaylight/netconf/config-persister-impl/src/main/resources/netconfOp/editConfig.xml b/opendaylight/netconf/config-persister-impl/src/main/resources/netconfOp/editConfig.xml index 8ec1c8c069..8f6ec9c4c2 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/resources/netconfOp/editConfig.xml +++ b/opendaylight/netconf/config-persister-impl/src/main/resources/netconfOp/editConfig.xml @@ -3,7 +3,7 @@ - replace + merge diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java index 577c039530..189476a5d1 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java @@ -127,10 +127,20 @@ public class SubnetConfig implements Cloneable, Serializable { return new Status(StatusCode.SUCCESS); } + private Status validateName() { + if (name == null || name.trim().isEmpty()) { + return new Status(StatusCode.BADREQUEST, "Invalid name"); + } + return new Status(StatusCode.SUCCESS); + } + public Status validate() { - Status status = validateSubnetAddress(); + Status status = validateName(); if (status.isSuccess()) { - status = validatePorts(this.nodeConnectors); + status = validateSubnetAddress(); + if (status.isSuccess()) { + status = validatePorts(this.nodeConnectors); + } } return status; }