diff options
author | 2016-03-22 17:57:16 +0100 | |
---|---|---|
committer | 2016-03-31 14:27:54 +0000 | |
commit | 3368459b88f4a1aca74eecf13216d1a3fafcc889 (patch) | |
tree | 96a7cdc140b800ac3288150b526496199f5bb695 /v3po/impl/src/main | |
parent | 1fb7cb0596bde05c0931c43e53fba98e74005f9d (diff) |
Dedicated NETCONF north interface for v3po
Change-Id: I3a001ef68f7ff43ec1b2a935dd474ec966cea878
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl/src/main')
7 files changed, 724 insertions, 2 deletions
diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index 7d0f19476..261cd3d6f 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -15,6 +15,7 @@ limitations under the License. --> <snapshot> + <!--TODO update required caps--> <required-capabilities> <capability>urn:opendaylight:params:xml:ns:yang:v3po:impl?module=v3po-impl&revision=2014-12-10</capability> <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability> @@ -36,6 +37,19 @@ </dom-broker> </module> </modules> + + <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> + <service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom"> + dom:dom-broker-osgi-registry + </type> + <instance> + <name>vpp-dom-broker</name> + <provider>/modules/module[type='v3po'][name='v3po-default'] + </provider> + </instance> + </service> + </services> </data> </configuration> </snapshot> diff --git a/v3po/impl/src/main/config/netconf-north-config.xml b/v3po/impl/src/main/config/netconf-north-config.xml new file mode 100644 index 000000000..44b610b72 --- /dev/null +++ b/v3po/impl/src/main/config/netconf-north-config.xml @@ -0,0 +1,457 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright (c) 2016 Cisco and/or its affiliates. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at: + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<!-- vi: set et smarttab sw=4 tabstop=4: --> + +<snapshot> + <configuration> + <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> + <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> + + <!-- In memory DS dedicated to NETCONF monitoring, notifications etc. --> + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-config-datastore-provider</type> + <name>netconf-config-store-service</name> + <inmemory-config-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider"> + <schema-service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type> + <name>yang-schema-service</name> + </schema-service> + </inmemory-config-datastore-provider> + </module> + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-operational-datastore-provider</type> + <name>netconf-operational-store-service</name> + <inmemory-operational-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider"> + <schema-service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type> + <name>yang-schema-service</name> + </schema-service> + </inmemory-operational-datastore-provider> + </module> + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-inmemory-data-broker</type> + <name>netconf-inmemory-data-broker</name> + + <schema-service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type> + <name>yang-schema-service</name> + </schema-service> + + <config-data-store> + <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type> + <name>netconf-config-store-service</name> + </config-data-store> + + <operational-data-store> + <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type> + <name>netconf-operational-store-service</name> + </operational-data-store> + </module> + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type> + <name>netconf-binding-data-broker</name> + <binding-forwarded-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl"> + <dom-async-broker> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type> + <name>netconf-inmemory-data-broker</name> + </dom-async-broker> + <schema-service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type> + <name>yang-schema-service</name> + </schema-service> + <binding-mapping-service> + <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type> + <name>runtime-mapping-singleton</name> + </binding-mapping-service> + </binding-forwarded-data-broker> + </module> + <module> + <!--binding-broker-osgi-registry--> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:v3po:impl">prefix:binding-broker-netconf</type> + <name>binding-broker-netconf</name> + <netconf-binding-broker> + <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> + <name>netconf-binding-data-broker</name> + </netconf-binding-broker> + </module> + <!-- END:In memory DS dedicated to NETCONF monitoring, notifications etc. --> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper"> + prefix:netconf-mdsal-mapper + </type> + <name>netconf-vpp-mapper</name> + <root-schema-service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service + </type> + <name>yang-schema-service</name> + </root-schema-service> + <root-schema-source-provider> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom"> + dom:yang-text-source-provider + </type> + <name>yang-text-source-provider</name> + </root-schema-source-provider> + <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper"> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom"> + dom:dom-broker-osgi-registry + </type> + <name>vpp-dom-broker</name> + </dom-broker> + <mapper-aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-mapper-registry + </type> + <name>vpp-mapper-aggregator-registry</name> + </mapper-aggregator> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + prefix:netconf-server-dispatcher-impl + </type> + <name>netconf-vpp-server-dispatcher</name> + <mappers xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + dom:netconf-northbound-mapper + </type> + <name>vpp-mapper-aggregator</name> + </mappers> + <server-monitor + xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-monitoring + </type> + <name>vpp-server-monitor</name> + </server-monitor> + <boss-thread-group + xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty"> + prefix:netty-threadgroup + </type> + <name>global-boss-group</name> + </boss-thread-group> + <worker-thread-group + xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty"> + prefix:netty-threadgroup + </type> + <name>global-worker-group</name> + </worker-thread-group> + <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer + </type> + <name>global-timer</name> + </timer> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring"> + prefix:netconf-mdsal-monitoring-mapper + </type> + <name>netconf-vpp-monitoring-mapper</name> + <server-monitoring xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-monitoring + </type> + <name>vpp-server-monitor</name> + </server-monitoring> + <binding-aware-broker + xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding"> + prefix:binding-broker-osgi-registry + </type> + <name>binding-broker-netconf</name> + </binding-aware-broker> + <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-mapper-registry + </type> + <name>vpp-mapper-aggregator-registry</name> + </aggregator> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + prefix:netconf-mapper-aggregator + </type> + <name>vpp-mapper-aggregator</name> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + prefix:netconf-server-monitoring-impl + </type> + <name>vpp-server-monitor</name> + <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl"> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + dom:netconf-northbound-mapper + </type> + <name>vpp-mapper-aggregator</name> + </aggregator> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + prefix:netconf-northbound-ssh + </type> + <name>netconf-vpp-ssh-server</name> + + <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh">7778</port> + <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty"> + prefix:netty-event-executor + </type> + <name>global-event-executor</name> + </event-executor> + <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty"> + prefix:netty-threadgroup + </type> + <name>global-worker-group</name> + </worker-thread-group> + <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool"> + prefix:threadpool + </type> + <name>global-netconf-ssh-scheduled-executor</name> + </processing-executor> + <dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-dispatcher + </type> + <name>netconf-vpp-server-dispatcher</name> + </dispatcher> + <auth-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:auth"> + prefix:netconf-auth-provider + </type> + <name>default-auth-provider</name> + </auth-provider> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification:impl"> + prefix:netconf-notification-manager + </type> + <name>vpp-netconf-notification-manager</name> + </module> + + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification"> + prefix:netconf-mdsal-notification-mapper + </type> + <name>netconf-vpp-notification-mapper</name> + <!--This is used to listen to netconf-state/capabilities changes to send out notifications--> + <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification"> + <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding"> + binding:binding-async-data-broker + </type> + <name>netconf-binding-data-broker</name> + </data-broker> + <!--This writes stream list into DS--> + <binding-aware-broker + xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding"> + prefix:binding-broker-osgi-registry + </type> + <name>binding-broker-netconf</name> + </binding-aware-broker> + <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-mapper-registry + </type> + <name>vpp-mapper-aggregator-registry</name> + </aggregator> + <notification-registry + xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"> + prefix:netconf-notification-registry + </type> + <name>vpp-netconf-notification-manager</name> + </notification-registry> + <notification-collector> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"> + prefix:netconf-notification-collector + </type> + <name>vpp-netconf-notification-manager</name> + </notification-collector> + </module> + + + <!--TCP endpoint for MD-SAL netconf server --> + <module> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp"> + prefix:netconf-northbound-tcp + </type> + <name>netconf-vpp-tcp-server</name> + <dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp"> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-dispatcher + </type> + <name>netconf-vpp-server-dispatcher</name> + </dispatcher> + <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp">7777</port> + </module> + + </modules> + + <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> + <!-- In memory DS dedicated to NETCONF monitoring, notifications etc. --> + <service> + <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type> + <instance> + <name>netconf-config-store-service</name> + <provider>/modules/module[type='inmemory-config-datastore-provider'][name='netconf-config-store-service']</provider> + </instance> + </service> + <service> + <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type> + <instance> + <name>netconf-operational-store-service</name> + <provider>/modules/module[type='inmemory-operational-datastore-provider'][name='netconf-operational-store-service']</provider> + </instance> + </service> + <service> + <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type> + <instance> + <name>netconf-inmemory-data-broker</name> + <provider>/modules/module[type='dom-inmemory-data-broker'][name='netconf-inmemory-data-broker']</provider> + </instance> + </service> + <service> + <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> + <instance> + <name>netconf-binding-data-broker</name> + <provider>/modules/module[type='binding-forwarded-data-broker'][name='netconf-binding-data-broker']</provider> + </instance> + </service> + <service> + <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type> + <instance> + <name>binding-broker-netconf</name> + <provider>/modules/module[type='binding-broker-netconf'][name='binding-broker-netconf']</provider> + </instance> + </service> + <!-- END:In memory DS dedicated to NETCONF monitoring, notifications etc. --> + + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-monitoring + </type> + <instance> + <name>vpp-server-monitor</name> + <provider>/modules/module[type='netconf-server-monitoring-impl'][name='vpp-server-monitor'] + </provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-northbound-mapper + </type> + <instance> + <name>netconf-vpp-mapper</name> + <provider>/modules/module[type='netconf-mdsal-mapper'][name='netconf-vpp-mapper']</provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-northbound-mapper + </type> + <instance> + <name>vpp-mapper-aggregator</name> + <provider>/modules/module[type='netconf-mapper-aggregator'][name='vpp-mapper-aggregator']</provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-mapper-registry + </type> + <instance> + <name>vpp-mapper-aggregator-registry</name> + <provider>/modules/module[type='netconf-mapper-aggregator'][name='vpp-mapper-aggregator']</provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound"> + prefix:netconf-server-dispatcher + </type> + <instance> + <name>netconf-vpp-server-dispatcher</name> + <provider> + /modules/module[type='netconf-server-dispatcher-impl'][name='netconf-vpp-server-dispatcher'] + </provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper"> + prefix:netconf-northbound-mapper + </type> + <instance> + <name>netconf-vpp-notification-mapper</name> + <provider> + /modules/module[type='netconf-mdsal-notification-mapper'][name='netconf-vpp-notification-mapper'] + </provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"> + prefix:netconf-notification-collector + </type> + <instance> + <name>vpp-netconf-notification-manager</name> + <provider> + /modules/module[type='netconf-notification-manager'][name='vpp-netconf-notification-manager'] + </provider> + </instance> + </service> + <service> + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"> + prefix:netconf-notification-registry + </type> + <instance> + <name>vpp-netconf-notification-manager</name> + <provider> + /modules/module[type='netconf-notification-manager'][name='vpp-netconf-notification-manager'] + </provider> + </instance> + </service> + </services> + + </data> + </configuration> + <required-capabilities> + <capability>urn:opendaylight:params:xml:ns:yang:v3po:impl?module=v3po-impl&revision=2014-12-10</capability> + <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability> + <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper?module=netconf-mdsal-mapper&revision=2015-01-14</capability> + <capability> + urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&revision=2015-02-18 + </capability> + <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:ssh?module=netconf-northbound-ssh&revision=2015-01-14</capability> + <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&revision=2015-04-23</capability> + <capability> + urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl?module=netconf-northbound-impl&revision=2015-01-12 + </capability> + <capability> + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled?module=threadpool-impl-scheduled&revision=2013-12-01 + </capability> + <capability> + urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification?module=netconf-mdsal-notification&revision=2015-08-03 + </capability> + </required-capabilities> +</snapshot> diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java index 8a0dead0e..4afd86099 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java @@ -23,20 +23,26 @@ import com.google.common.util.concurrent.Futures; import io.fd.honeycomb.v3po.impl.data.VppDataBrokerInitializationProvider; import io.fd.honeycomb.v3po.impl.data.VppReaderRegistry; import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; import javax.annotation.Nonnull; +import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.BrokerService; +import org.opendaylight.controller.sal.core.api.Consumer; +import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.SoftwareLoopback; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType; @@ -54,10 +60,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.openvpp.vppjapi.vppApi; import org.openvpp.vppjapi.vppInterfaceDetails; +import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class V3poProvider implements BindingAwareProvider, AutoCloseable { +public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker { private static final Logger LOG = LoggerFactory.getLogger(V3poProvider.class); private final Broker domBroker; @@ -209,4 +216,85 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable { vppDataBrokerInitializationProvider.close(); } } + + // DomBroker functionality below. Should go out of here. TODO do that when cleaning up this provider + + @Override + public ConsumerSession registerConsumer(final Consumer consumer) { + final SimpleConsumerSession session = new SimpleConsumerSession( + Collections.<Class<? extends BrokerService>, BrokerService>singletonMap(DOMDataBroker.class, + vppDataBrokerInitializationProvider.getBroker().get())); + consumer.onSessionInitiated(session); + return session; + } + + @Deprecated + @Override + public ConsumerSession registerConsumer(final Consumer consumer, final BundleContext bundleContext) { + throw new UnsupportedOperationException(); + } + + @Override + public ProviderSession registerProvider(final Provider provider) { + final SimpleProviderSession session = new SimpleProviderSession( + Collections.<Class<? extends BrokerService>, BrokerService>singletonMap(DOMDataBroker.class, + vppDataBrokerInitializationProvider.getBroker().get())); + provider.onSessionInitiated(session); + return session; + } + + @Override + public ProviderSession registerProvider(final Provider provider, final BundleContext bundleContext) { + throw new UnsupportedOperationException(); + } + + @NotThreadSafe + private static class SimpleConsumerSession implements ConsumerSession { + private boolean closed; + private final Map<Class<? extends BrokerService>, BrokerService> services; + + private SimpleConsumerSession(final Map<Class<? extends BrokerService>, BrokerService> services) { + this.services = services; + } + + @Override + public boolean isClosed() { + return closed; + } + + @Override + public <T extends BrokerService> T getService(final Class<T> aClass) { + return (T)services.get(aClass); + } + + @Override + public void close() { + closed = true; + } + } + + @NotThreadSafe + private static class SimpleProviderSession implements ProviderSession { + private boolean closed; + private final Map<Class<? extends BrokerService>, BrokerService> services; + + private SimpleProviderSession(final Map<Class<? extends BrokerService>, BrokerService> services) { + this.services = services; + } + + @Override + public boolean isClosed() { + return closed; + } + + @Override + public <T extends BrokerService> T getService(final Class<T> aClass) { + return (T)services.get(aClass); + } + + @Override + public void close() { + closed = true; + } + } } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java index b7a24ea90..129a1b84b 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java @@ -85,6 +85,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto private final ReaderRegistry readerRegistry; private final InstanceIdentifier<Node> mountPointPath; private ObjectRegistration<DOMMountPoint> mountPointRegistration; + private DOMDataBroker broker; public VppDataBrokerInitializationProvider(@Nonnull final DataBroker bindingBroker, final ReaderRegistry readerRegistry) { this.bindingBroker = Preconditions.checkNotNull(bindingBroker, "bindingBroker should not be null"); @@ -116,7 +117,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path); mountPointBuilder.addInitialSchemaContext(globalContext); - final DOMDataBroker broker = initVppDataBroker(globalContext, serializer); + broker = initVppDataBroker(globalContext, serializer); mountPointBuilder.addService(DOMDataBroker.class, broker); mountPointRegistration = mountPointBuilder.register(); @@ -245,11 +246,20 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto new LoggingFuturesCallBack<Void>("Initializing VPP config DataTree failed", LOG)); } + public Optional<DOMDataBroker> getBroker() { + return Optional.fromNullable(broker); + } + @Override public void close() throws Exception { if (mountPointRegistration != null) { mountPointRegistration.close(); } + + if (broker != null) { + broker = null; + } + // remove MD-SAL placeholder data for VPP mount point: final WriteTransaction rwTx = bindingBroker.newWriteOnlyTransaction(); // does not fail if data is not present: diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java new file mode 100644 index 000000000..48d227d01 --- /dev/null +++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java @@ -0,0 +1,117 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.BindingAwareService; +import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.RpcService; +import org.osgi.framework.BundleContext; + +public class NetconfBindingBrokerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfBindingBrokerModule { + public NetconfBindingBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NetconfBindingBrokerModule(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.v3po.impl.rev141210.NetconfBindingBrokerModule 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() { + return new FakeBindingAwareBroker(getNetconfBindingBrokerDependency()); + } + + private static class FakeBindingAwareBroker implements BindingAwareBroker, AutoCloseable { + + private DataBroker netconfBindingBrokerDependency; + + public FakeBindingAwareBroker(final DataBroker netconfBindingBrokerDependency) { + + this.netconfBindingBrokerDependency = netconfBindingBrokerDependency; + } + + @Deprecated + @Override + public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer, + final BundleContext bundleContext) { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer) { + final ConsumerContext consumerContext = new ConsumerContext() { + @Override + public <T extends BindingAwareService> T getSALService(final Class<T> aClass) { + return aClass.equals(DataBroker.class) + ? (T) netconfBindingBrokerDependency + : null; + } + + @Override + public <T extends RpcService> T getRpcService(final Class<T> aClass) { + return null; + } + }; + bindingAwareConsumer.onSessionInitialized(consumerContext); + return consumerContext; + } + + @Override + public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider, + final BundleContext bundleContext) { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider) { + final ProviderContext context = new ProviderContext() { + @Override + public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener( + final L l) { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public <T extends RpcService> T getRpcService(final Class<T> aClass) { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> aClass, final T t) + throws IllegalStateException { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation( + final Class<T> aClass, final T t) throws IllegalStateException { + throw new UnsupportedOperationException("Unsupported"); + } + + @Override + public <T extends BindingAwareService> T getSALService(final Class<T> aClass) { + return aClass.equals(DataBroker.class) + ? (T) netconfBindingBrokerDependency + : null; } + }; + bindingAwareProvider.onSessionInitiated(context); + return context; + } + + @Override + public void close() throws Exception { + netconfBindingBrokerDependency = null; + } + } +} + diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java new file mode 100644 index 000000000..b64b0b1e1 --- /dev/null +++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: v3po-impl yang module local name: binding-broker-netconf +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Wed Mar 23 10:45:48 CET 2016 +* +* 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.v3po.impl.rev141210; +public class NetconfBindingBrokerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfBindingBrokerModuleFactory { + +} diff --git a/v3po/impl/src/main/yang/v3po-impl.yang b/v3po/impl/src/main/yang/v3po-impl.yang index 2e113e566..12f9d6f13 100644 --- a/v3po/impl/src/main/yang/v3po-impl.yang +++ b/v3po/impl/src/main/yang/v3po-impl.yang @@ -17,6 +17,7 @@ module v3po-impl { identity v3po { base config:module-type; + config:provided-service dom:dom-broker-osgi-registry; config:java-name-prefix V3po; } @@ -42,4 +43,26 @@ module v3po-impl { } } } + + identity binding-broker-netconf { + base config:module-type; + config:provided-service md-sal-binding:binding-broker-osgi-registry; + config:java-name-prefix NetconfBindingBroker; + } + + augment "/config:modules/config:module/config:configuration" { + case binding-broker-netconf { + when "/config:modules/config:module/config:type = 'binding-broker-netconf'"; + + container netconf-binding-broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-async-data-broker; + } + } + } + + } + } } |