From 82aaea967995bcc70fdd56d27dbf1f517804423f Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Fri, 27 Mar 2015 12:29:44 +0100 Subject: [PATCH] added yang file describing openflowplugin-impl as CoSS module Change-Id: I0ed0158e4815516e9255301c89f9bf31f460e82a Signed-off-by: Martin Bobak --- .../api/openflow/OpenFlowPluginProvider.java | 40 +++++ .../impl/OpenflowPluginProviderImpl.java | 59 ++++++++ .../rev150327/OpenFlowProviderModule.java | 29 ++++ .../OpenFlowProviderModuleFactory.java | 13 ++ .../src/main/yang/openflow-plugin-impl.yang | 141 ++++++++++++++++++ 5 files changed, 282 insertions(+) create mode 100644 openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginProviderImpl.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModule.java create mode 100644 openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModuleFactory.java create mode 100644 openflowplugin-impl/src/main/yang/openflow-plugin-impl.yang diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java new file mode 100644 index 0000000000..3368056332 --- /dev/null +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 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.openflowplugin.api.openflow; + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole; +import java.util.Collection; + +/** + * Created by Martin Bobak on 27.3.2015. + */ +public interface OpenFlowPluginProvider extends AutoCloseable { + + + public void onSessionInitiated(BindingAwareBroker.ProviderContext session); + + /** + * Method sets openflow java's connection providers. + */ + public void setSwitchConnectionProviders(Collection switchConnectionProvider); + + + /** + * Method sets role of this application in clustered environment. + */ + public void setRole(OfpRole role); + + /** + * Method initializes all DeviceManager, RpcManager and related contexts. + */ + public void initialize(); + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginProviderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginProviderImpl.java new file mode 100644 index 0000000000..3a17dee453 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginProviderImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 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.openflowplugin.impl; + + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager; +import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager; +import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager; +import org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl; +import org.opendaylight.openflowplugin.impl.rpc.RpcManagerImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole; +import java.util.Collection; + +/** + * Created by Martin Bobak on 27.3.2015. + */ +public class OpenflowPluginProviderImpl implements OpenFlowPluginProvider { + + private DeviceManager deviceManager; + private RpcManager rpcManager; + private BindingAwareBroker.ProviderContext providerContext; + private StatisticsManager statisticsManager; + + @Override + public void onSessionInitiated(final BindingAwareBroker.ProviderContext session) { + providerContext = session; + } + + @Override + public void setSwitchConnectionProviders(final Collection switchConnectionProvider) { + + } + + @Override + public void setRole(final OfpRole role) { + + } + + @Override + public void initialize() { + deviceManager = new DeviceManagerImpl(); + rpcManager = new RpcManagerImpl(providerContext); + //TODO : initialize statistics manager + } + + @Override + public void close() throws Exception { + + } +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModule.java b/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModule.java new file mode 100644 index 0000000000..168f497ec8 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModule.java @@ -0,0 +1,29 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev150327; + +import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider; +import org.opendaylight.openflowplugin.impl.OpenflowPluginProviderImpl; + +public class OpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev150327.AbstractOpenFlowProviderModule { + public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev150327.OpenFlowProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + OpenFlowPluginProvider openflowPluginProvider = new OpenflowPluginProviderImpl(); + + openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency()); + openflowPluginProvider.initialize(); + return openflowPluginProvider; + } + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModuleFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModuleFactory.java new file mode 100644 index 0000000000..abffe30ca7 --- /dev/null +++ b/openflowplugin-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/common/config/impl/rev150327/OpenFlowProviderModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: openflow-plugin-provider-impl yang module local name: openflow-plugin-provider-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Mar 27 12:20:46 CET 2015 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev150327; +public class OpenFlowProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev150327.AbstractOpenFlowProviderModuleFactory { + +} diff --git a/openflowplugin-impl/src/main/yang/openflow-plugin-impl.yang b/openflowplugin-impl/src/main/yang/openflow-plugin-impl.yang new file mode 100644 index 0000000000..23af39125f --- /dev/null +++ b/openflowplugin-impl/src/main/yang/openflow-plugin-impl.yang @@ -0,0 +1,141 @@ +module openflow-plugin-provider-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:openflow:common:config:impl"; + prefix "openflow-plugin-provider-impl"; + + import config {prefix config; revision-date 2013-04-05;} + import rpc-context { prefix rpcx; revision-date 2013-06-17; } + import openflow-provider {prefix openflow-provider;} + import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} + import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} + + + description + "openflow-plugin-custom-config-impl"; + + revision "2015-03-27" { + description + "Second openflow plugin implementation."; + } + + identity openflow-plugin-provider-impl { + base config:module-type; + config:provided-service openflow-provider:openflow-provider; + config:java-name-prefix OpenFlowProvider; + } + +//TODO this needs to be split to API and IMPL - crate new yang describing API in openflowplugin-api +//TODO this needs to be split to API and IMPL - crate new yang describing IMPL in openflowplugin-impl +/* + identity msg-spy-service { + description + "MessageCountDumperServiceInterface as a MsgSpyService interface identity"; + base config:service-type; + config:java-class "org.opendaylight.openflowplugin.api.statistics.MessageCountDumper"; + } + + identity msg-spy-service-impl { + description + "This is the definition of MsgSpyService implementation module identity."; + base config:module-type; + config:provided-service msg-spy-service; + config:java-name-prefix MsgSpyService; + } +*/ + // role of OFPlugin instance + typedef ofp-role { + type enumeration { + enum NOCHANGE { + description "no change to role"; + } + enum BECOMEMASTER { + description "promote current role to MASTER"; + } + enum BECOMESLAVE { + description "demote current role to SLAVE"; + } + } + } + + augment "/config:modules/config:module/config:configuration" { + case openflow-plugin-provider-impl { + when "/config:modules/config:module/config:type = 'openflow-plugin-provider-impl'"; + + container binding-aware-broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-broker-osgi-registry; + } + } + } + list openflow-switch-connection-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; + } + } + } + leaf role { + type ofp-role; + default "NOCHANGE"; + } + } + +/* + case msg-spy-service-impl { + when "/config:modules/config:module/config:type = 'msg-spy-service-impl'"; + + container openflow-plugin-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-provider:openflow-provider; + } + } + } + } +*/ + } + + +/* + augment "/config:modules/config:module/config:state" { + case msg-spy-service-impl { + when "/config:modules/config:module/config:type = 'msg-spy-service-impl'"; + + description + "MXBean designed for Message Statistic providing to JConsole."; + + leaf msgStatistics { + type string; + } + + rpcx:rpc-context-instance "make-msg-statistics-rpc"; + } + } +*/ + + identity make-msg-statistics-rpc; + + rpc make-msg-statistics { + + description + "Shortcut JMX call to getMsgStatistics."; + + input { + uses rpcx:rpc-context-ref { + refine context-instance { + rpcx:rpc-context-instance make-msg-statistics-rpc; + } + } + } + + output { + leaf result { + type string; + } + } + } +} -- 2.36.6