The wiring was added to the pcep-impl.xml file.
Moved the max-unknown-messages and tls config to a new
pcep-dispatcher-config container in the pcep-app-config.yang. This
changed the package for the generated Tls class.
The md5 factpry wiring was ommitted b/c it is being removed in a another patch
anyway. The PCEPTopologyProviderModule did some fancy checking to see if md5 was
enabled. This checking was removed to avoid compilation error.
The PCEPDispatcherImplModule was deprecated but still remains for now
to provide the PCEPDispatcher instance created via blueprint to the
config system so it can be injected into other users. Once the other user(s)
are converted to blueprint then the config yang, Module classes can be removed.
The SimplePCEPExtensionProviderContextModule and yang were removed as
all users are now converted to blueprint. Same with
PCEPSessionProposalFactoryImplModule.
Change-Id: I8c5a12cedbafbe54f492d01f6d0a3c608f49508a
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
base "config:service-type";
config:java-class "org.opendaylight.protocol.pcep.PCEPDispatcher";
- }
-
- identity pcep-session-proposal-factory {
- description
- "Service representing a PCEP session proposal factory service. The service
- provides initial session attributes given by the user.";
-
- base "config:service-type";
- config:java-class "org.opendaylight.protocol.pcep.PCEPSessionProposalFactory";
config:disable-osgi-service-registration;
}
-
- identity pcep-capability {
- description "Service for storing usability of specific capabilities during
- opened PCEP session.";
- base "config:service-type";
- config:java-class "org.opendaylight.protocol.pcep.PCEPCapability";
- }
}
-->
<snapshot>
<required-capabilities>
- <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:netty?module=netty&revision=2013-11-19</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:impl?module=odl-pcep-impl-cfg&revision=2013-06-27</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:pcep:spi?module=odl-pcep-spi-cfg&revision=2013-11-15</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:programming:spi?module=odl-programming-spi-cfg&revision=2013-11-15</capability>
</required-capabilities>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">prefix:pcep-extensions-impl</type>
- <name>global-pcep-extensions</name>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-session-proposal-factory-impl</type>
- <name>global-pcep-session-proposal-factory</name>
- </module>
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-dispatcher-impl</type>
<name>global-pcep-dispatcher</name>
- <pcep-extensions>
- <type xmlns:pcepspi="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">pcepspi:extensions</type>
- <name>global-pcep-extensions</name>
- </pcep-extensions>
- <pcep-session-proposal-factory>
- <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
- <name>global-pcep-session-proposal-factory</name>
- </pcep-session-proposal-factory>
- <boss-group>
- <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
- <name>global-boss-group</name>
- </boss-group>
- <worker-group>
- <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
- <name>global-worker-group</name>
- </worker-group>
- <!--
- Uncomment this block to enable PCEPS TLS communication. Change example values as needed.
- <tls>
- <keystore>configuration/ctl.jks</keystore>
- <keystore-type>JKS</keystore-type>
- <keystore-path-type>PATH</keystore-path-type>
- <keystore-password>opendaylight</keystore-password>
- <truststore>configuration/truststore.jks</truststore>
- <truststore-type>JKS</truststore-type>
- <truststore-path-type>PATH</truststore-path-type>
- <truststore-password>opendaylight</truststore-password>
- <certificate-password>opendaylight</certificate-password>
- </tls>
- -->
</module>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
- <service>
- <type xmlns:pcepspi="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">pcepspi:extensions</type>
- <instance>
- <name>global-pcep-extensions</name>
- <provider>/config/modules/module[name='pcep-extensions-impl']/instance[name='global-pcep-extensions']</provider>
- </instance>
- </service>
<service>
<type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-dispatcher</type>
<instance>
<provider>/config/modules/module[name='pcep-dispatcher-impl']/instance[name='global-pcep-dispatcher']</provider>
</instance>
</service>
- <service>
- <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
- <instance>
- <name>global-pcep-session-proposal-factory</name>
- <provider>/config/modules/module[name='pcep-session-proposal-factory-impl']/instance[name='global-pcep-session-proposal-factory']</provider>
- </instance>
- </service>
</services>
</data>
*/
package org.opendaylight.controller.config.yang.pcep.impl;
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.osgi.framework.BundleContext;
/**
- *
+ * @deprecated Replaced by blueprint wiring
*/
-public final class PCEPDispatcherImplModule extends org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPDispatcherImplModule {
-
- private static final String VALUE_IS_NOT_SET = "value is not set.";
- private static final String KEYSTORE = "keystore";
- private static final String TRUSTSTORE = "truststore";
- private static final String PASSWORD = " password ";
- private static final String LOCATION = " location ";
- private static final String TYPE = " type ";
- private static final String PATH_TYPE = " path" + TYPE;
+@Deprecated
+public final class PCEPDispatcherImplModule extends AbstractPCEPDispatcherImplModule {
+ private BundleContext bundleContext;
public PCEPDispatcherImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
}
@Override
- public void validate() {
- super.validate();
- JmxAttributeValidationException.checkNotNull(getMaxUnknownMessages(), VALUE_IS_NOT_SET, maxUnknownMessagesJmxAttribute);
- JmxAttributeValidationException.checkCondition(getMaxUnknownMessages() > 0, "Parameter 'maxUnknownMessages' "
- + "must be greater than 0", maxUnknownMessagesJmxAttribute);
- if (getTls() != null) {
- JmxAttributeValidationException.checkNotNull(getTls().getCertificatePassword(), "certificate" + PASSWORD + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getKeystore(), KEYSTORE + LOCATION + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getKeystorePassword(), KEYSTORE + PASSWORD + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getKeystorePathType(), KEYSTORE + PATH_TYPE + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getKeystoreType(), KEYSTORE + TYPE + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getTruststore(), TRUSTSTORE + LOCATION + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getTruststorePassword(), TRUSTSTORE + PASSWORD + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getTruststorePathType(), TRUSTSTORE + PATH_TYPE + VALUE_IS_NOT_SET, tlsJmxAttribute);
- JmxAttributeValidationException.checkNotNull(getTls().getTruststoreType(), TRUSTSTORE + TYPE + VALUE_IS_NOT_SET, tlsJmxAttribute);
- }
+ public AutoCloseable createInstance() {
+ final WaitingServiceTracker<PCEPDispatcher> tracker =
+ WaitingServiceTracker.create(PCEPDispatcher.class, bundleContext);
+ final PCEPDispatcher service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ return Reflection.newProxy(AutoCloseablePCEPDispatcher.class, new AbstractInvocationHandler() {
+ @Override
+ protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("close")) {
+ tracker.close();
+ return null;
+ } else {
+ return method.invoke(service, args);
+ }
+ }
+ });
}
- @Override
- public java.lang.AutoCloseable createInstance() {
- final DefaultPCEPSessionNegotiatorFactory negFactory = new DefaultPCEPSessionNegotiatorFactory(getPcepSessionProposalFactoryDependency(), getMaxUnknownMessages(), getTls());
+ void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
- return new PCEPDispatcherImpl(getPcepExtensionsDependency().getMessageHandlerRegistry(), negFactory, getBossGroupDependency(), getWorkerGroupDependency());
+ private static interface AutoCloseablePCEPDispatcher extends PCEPDispatcher, AutoCloseable {
}
}
*/
package org.opendaylight.controller.config.yang.pcep.impl;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
/**
-*
-*/
-public class PCEPDispatcherImplModuleFactory extends
- org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPDispatcherImplModuleFactory {
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class PCEPDispatcherImplModuleFactory extends AbstractPCEPDispatcherImplModuleFactory {
+ @Override
+ public PCEPDispatcherImplModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ PCEPDispatcherImplModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+ PCEPDispatcherImplModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+ oldInstance, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+ @Override
+ public PCEPDispatcherImplModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ PCEPDispatcherImplModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
+++ /dev/null
-/*
- * 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
- */
-/**
- * Generated file
-
- * Generated from: yang module name: pcep-impl yang module local name: pcep-session-proposal-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:16:39 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.pcep.impl;
-
-import com.google.common.reflect.AbstractInvocationHandler;
-import com.google.common.reflect.Reflection;
-import java.lang.reflect.Method;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.osgi.framework.BundleContext;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public final class PCEPSessionProposalFactoryImplModule extends AbstractPCEPSessionProposalFactoryImplModule {
- private BundleContext bundleContext;
-
- public PCEPSessionProposalFactoryImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
- }
-
- public PCEPSessionProposalFactoryImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final PCEPSessionProposalFactoryImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- final WaitingServiceTracker<PCEPSessionProposalFactory> tracker =
- WaitingServiceTracker.create(PCEPSessionProposalFactory.class, bundleContext);
- final PCEPSessionProposalFactory service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-
- return Reflection.newProxy(AutoCloseablePCEPSessionProposalFactory.class, new AbstractInvocationHandler() {
- @Override
- protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
- if (method.getName().equals("close")) {
- tracker.close();
- return null;
- } else {
- return method.invoke(service, args);
- }
- }
- });
- }
-
- void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- private static interface AutoCloseablePCEPSessionProposalFactory extends PCEPSessionProposalFactory, AutoCloseable {
- }
-}
+++ /dev/null
-/*
- * 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
- */
-/**
- * Generated file
-
- * Generated from: yang module name: pcep-impl yang module local name: pcep-session-proposal-factory-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Wed Nov 06 13:16:39 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.pcep.impl;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.osgi.framework.BundleContext;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public class PCEPSessionProposalFactoryImplModuleFactory extends AbstractPCEPSessionProposalFactoryImplModuleFactory {
- @Override
- public PCEPSessionProposalFactoryImplModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
- PCEPSessionProposalFactoryImplModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
- PCEPSessionProposalFactoryImplModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
- oldInstance, bundleContext);
- module.setBundleContext(bundleContext);
- return module;
- }
-
- @Override
- public PCEPSessionProposalFactoryImplModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
- BundleContext bundleContext) {
- PCEPSessionProposalFactoryImplModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
- module.setBundleContext(bundleContext);
- return module;
- }
-}
import java.util.concurrent.TimeoutException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
import org.opendaylight.protocol.pcep.impl.spi.Util;
import org.opendaylight.protocol.pcep.impl.tls.SslContextFactory;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Promise;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Promise;
import java.net.InetSocketAddress;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
import org.opendaylight.protocol.pcep.PCEPPeerProposal;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PcepDispatcherConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessionNegotiatorFactory {
private final PCEPSessionProposalFactory spf;
this.tlsConfiguration = tlsConfiguration;
}
+ public DefaultPCEPSessionNegotiatorFactory(final PCEPSessionProposalFactory spf, final PcepDispatcherConfig config) {
+ this(spf, config.getMaxUnknownMessages(), config.getTls());
+ }
+
@Override
protected AbstractPCEPSessionNegotiator createNegotiator(final Promise<PCEPSessionImpl> promise, final PCEPSessionListener listener,
final Channel channel, final short sessionId, final PCEPPeerProposal peerProposal) {
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.PathType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PathType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
<argument ref="pcepCapabilities"/>
</bean>
- <service ref="sessionProposalFactory" interface="org.opendaylight.protocol.pcep.PCEPSessionProposalFactory"/>
+ <!-- PCEPDispatcher -->
+
+ <reference id="pcepExtensionContext" interface="org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext"/>
+ <reference id="globalBossGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-boss-group"/>
+ <reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
+
+ <odl:clustered-app-config id="pcepDispatcherConfig"
+ binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PcepDispatcherConfig"/>
+
+ <bean id="pcepSessionNegotiatorFactory" class="org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory">
+ <argument ref="sessionProposalFactory"/>
+ <argument ref="pcepDispatcherConfig"/>
+ </bean>
+
+ <bean id="pcepDispatcher" class="org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl">
+ <argument>
+ <bean factory-ref="pcepExtensionContext" factory-method="getMessageHandlerRegistry"/>
+ </argument>
+ <argument ref="pcepSessionNegotiatorFactory"/>
+ <argument ref="globalBossGroup"/>
+ <argument ref="globalWorkerGroup"/>
+ </bean>
+
+ <service ref="pcepDispatcher" interface="org.opendaylight.protocol.pcep.PCEPDispatcher"/>
</blueprint>
\ No newline at end of file
import config { prefix config; revision-date 2013-04-05; }
import odl-pcep-api-cfg { prefix pcep; revision-date 2013-04-09; }
- import odl-pcep-spi-cfg { prefix spi; revision-date 2013-11-15; }
- import netty { prefix netty; revision-date 2013-11-19; }
organization "Cisco Systems, Inc.";
"Initial revision";
}
- typedef path-type {
- type enumeration {
- enum "PATH";
- enum "CLASSPATH";
- }
- }
-
- typedef store-type {
- type enumeration {
- enum "JKS";
- enum "PKCS12";
- }
- }
-
identity pcep-dispatcher-impl {
base config:module-type;
config:provided-service pcep:pcep-dispatcher;
augment "/config:modules/config:module/config:configuration" {
case pcep-dispatcher-impl {
when "/config:modules/config:module/config:type = 'pcep-dispatcher-impl'";
-
- leaf max-unknown-messages {
- type uint16;
- default 5;
- }
-
- container pcep-extensions {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity spi:consumer-extensions;
- }
- }
- }
-
- container pcep-session-proposal-factory {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity pcep:pcep-session-proposal-factory;
- }
- }
- }
-
- container boss-group {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity netty:netty-threadgroup;
- }
- }
- }
-
- container worker-group {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity netty:netty-threadgroup;
- }
- }
- }
-
- container tls {
- leaf keystore {
- description "keystore location";
- type string;
- mandatory true;
- }
- leaf keystore-type {
- description "keystore type (JKS or PKCS12)";
- type store-type;
- mandatory true;
- }
- leaf keystore-path-type {
- description "keystore path type (CLASSPATH or PATH)";
- type path-type;
- mandatory true;
- }
- leaf keystore-password {
- description "password protecting keystore";
- type string;
- mandatory true;
- }
- leaf certificate-password {
- description "password protecting certificate";
- type string;
- mandatory true;
- }
- leaf truststore {
- description "truststore location";
- type string;
- mandatory true;
- }
- leaf truststore-type {
- description "truststore type (JKS or PKCS12)";
- type store-type;
- mandatory true;
- }
- leaf truststore-path-type {
- description "truststore path type (CLASSPATH or PATH)";
- type path-type;
- mandatory true;
- }
- leaf truststore-password {
- description "password protecting truststore";
- type string;
- mandatory true;
- }
- }
- }
- }
-
- identity pcep-session-proposal-factory-impl {
- base config:module-type;
- config:java-name-prefix "PCEPSessionProposalFactoryImpl";
- config:provided-service pcep:pcep-session-proposal-factory;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case pcep-session-proposal-factory-impl {
- when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-impl'";
}
}
}
default 30;
}
}
+
+ typedef path-type {
+ type enumeration {
+ enum "PATH";
+ enum "CLASSPATH";
+ }
+ }
+
+ typedef store-type {
+ type enumeration {
+ enum "JKS";
+ enum "PKCS12";
+ }
+ }
+
+ container pcep-dispatcher-config {
+ leaf max-unknown-messages {
+ type uint16 {
+ range "1..max";
+ }
+ default 5;
+ }
+
+ container tls {
+ presence true;
+ leaf keystore {
+ description "keystore location";
+ type string;
+ mandatory true;
+ }
+ leaf keystore-type {
+ description "keystore type (JKS or PKCS12)";
+ type store-type;
+ mandatory true;
+ }
+ leaf keystore-path-type {
+ description "keystore path type (CLASSPATH or PATH)";
+ type path-type;
+ mandatory true;
+ }
+ leaf keystore-password {
+ description "password protecting keystore";
+ type string;
+ mandatory true;
+ }
+ leaf certificate-password {
+ description "password protecting certificate";
+ type string;
+ mandatory true;
+ }
+ leaf truststore {
+ description "truststore location";
+ type string;
+ mandatory true;
+ }
+ leaf truststore-type {
+ description "truststore type (JKS or PKCS12)";
+ type store-type;
+ mandatory true;
+ }
+ leaf truststore-path-type {
+ description "truststore path type (CLASSPATH or PATH)";
+ type path-type;
+ mandatory true;
+ }
+ leaf truststore-password {
+ description "password protecting truststore";
+ type string;
+ mandatory true;
+ }
+ }
+ }
}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.yang.pcep.impl;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import io.netty.channel.EventLoopGroup;
-import java.util.Collections;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
-import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleMXBean;
-import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleMXBean;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
-import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.PathType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.StoreType;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-public class PCEPDispatcherImplModuleTest extends AbstractConfigTest {
-
- private static final String INSTANCE_NAME = "pcep-dispatcher-impl";
- private static final String FACTORY_NAME = PCEPDispatcherImplModuleFactory.NAME;
-
- private static final String THREADGROUP_FACTORY_NAME = NettyThreadgroupModuleFactory.NAME;
- private static final String BOSS_TG_INSTANCE_NAME = "boss-group";
- private static final String WORKER_TG_INSTANCE_NAME = "worker-group";
-
- private static final String EXTENSION_INSTANCE_NAME = "pcep-extension-privider";
- private static final String EXTENSION_FACTORYNAME = SimplePCEPExtensionProviderContextModuleFactory.NAME;
-
- private static final String STORE_PASSWORD = "opendaylight";
- private static final String KEYSTORE = "ctl.jks";
- private static final String TRUSTSTORE = "truststore.jks";
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new PCEPDispatcherImplModuleFactory(), new PCEPSessionProposalFactoryImplModuleFactory(), new NettyThreadgroupModuleFactory(), new SimplePCEPExtensionProviderContextModuleFactory()));
-
- doAnswer(new Answer<Filter>() {
- @Override
- public Filter answer(InvocationOnMock invocation) {
- String str = invocation.getArgumentAt(0, String.class);
- Filter mockFilter = mock(Filter.class);
- doReturn(str).when(mockFilter).toString();
- return mockFilter;
- }
- }).when(mockedContext).createFilter(anyString());
- doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
-
- setupMockService(EventLoopGroup.class, mock(EventLoopGroup.class));
- setupMockService(PCEPExtensionProviderContext.class, new SimplePCEPExtensionProviderContext());
- setupMockService(PCEPSessionProposalFactory.class, new BasePCEPSessionProposalFactory(120, 30,
- Collections.emptyList()));
- }
-
- private void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
- final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(anyString(), contains(serviceInterface.getName()));
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(serviceInterface.getName(), null);
- doReturn(instance).when(mockedContext).getService(mockServiceRef);
- }
-
- @Test
- public void testValidationExceptionMaxUnknownMessagesNotSet() throws Exception {
- try {
- createDispatcherInstance(null);
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("MaxUnknownMessages value is not set"));
- }
- }
-
- @Test
- public void testValidationExceptionMaxUnknownMessagesMinValue() throws Exception {
- try {
- createDispatcherInstance(0);
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("must be greater than 0"));
- }
- }
-
- @Test
- public void testValidationExceptionCertificatePassword() throws Exception {
- try {
- createDispatcherInstance(1, createTls(null, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("certificate password"));
- }
- }
-
- @Test
- public void testValidationExceptionKeystoreLocation() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, null, STORE_PASSWORD, PathType.PATH, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("keystore location"));
- }
- }
-
- @Test
- public void testValidationExceptionKeystorePassword() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, null, PathType.PATH, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("keystore password"));
- }
- }
-
- @Test
- public void testValidationExceptionKeystorePathType() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, null, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("keystore path type"));
- }
- }
-
- @Test
- public void testValidationExceptionKeystoreType() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, null, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("keystore type"));
- }
- }
-
- @Test
- public void testValidationExceptionTruststoreLocation() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS, null, STORE_PASSWORD,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("truststore location"));
- }
- }
-
- @Test
- public void testValidationExceptionTruststorePassword() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS, TRUSTSTORE, null,
- PathType.PATH, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("truststore password"));
- }
- }
-
- @Test
- public void testValidationExceptionTruststorePathType() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- null, StoreType.JKS));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("truststore path type"));
- }
- }
-
- @Test
- public void testValidationExceptionTruststoreType() throws Exception {
- try {
- createDispatcherInstance(1, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS, TRUSTSTORE, STORE_PASSWORD,
- PathType.PATH, null));
- fail();
- } catch (final ValidationException e) {
- assertTrue(e.getMessage().contains("truststore type"));
- }
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createDispatcherInstance(5);
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 5, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createDispatcherInstance(5);
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 5);
- }
-
- @Test
- public void testReconfigure() throws Exception {
- createDispatcherInstance(5);
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final PCEPDispatcherImplModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
- PCEPDispatcherImplModuleMXBean.class);
- mxBean.setMaxUnknownMessages(10);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 1, 4);
- }
-
- @Test
- public void testCreateBeanWithTls() throws Exception {
- final CommitStatus status = createDispatcherInstance(5, createTls(STORE_PASSWORD, KEYSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS,
- TRUSTSTORE, STORE_PASSWORD, PathType.PATH, StoreType.JKS));
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 5, 0, 0);
- }
-
- private CommitStatus createDispatcherInstance(final Integer maxUnknownMessages) throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createDispatcherInstance(transaction, maxUnknownMessages);
- return transaction.commit();
- }
-
- private CommitStatus createDispatcherInstance(final Integer maxUnknownMessages, final Tls tls) throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- createDispatcherInstance(transaction, maxUnknownMessages, tls);
- return transaction.commit();
- }
-
- public static ObjectName createDispatcherInstance(final ConfigTransactionJMXClient transaction, final Integer maxUnknownMessages)
- throws Exception {
- final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final PCEPDispatcherImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, PCEPDispatcherImplModuleMXBean.class);
- mxBean.setPcepSessionProposalFactory(createSessionProposalFactoryInstance(transaction));
- mxBean.setMaxUnknownMessages(maxUnknownMessages);
- mxBean.setBossGroup(createThreadGroupInstance(transaction, 10, BOSS_TG_INSTANCE_NAME));
- mxBean.setWorkerGroup(createThreadGroupInstance(transaction, 10, WORKER_TG_INSTANCE_NAME));
- mxBean.setPcepExtensions(createExtensionsInstance(transaction));
- return nameCreated;
- }
-
- private static ObjectName createSessionProposalFactoryInstance(final ConfigTransactionJMXClient transaction)
- throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(PCEPSessionProposalFactoryImplModuleFactory.NAME,
- "pcep-session-proposal-factory-impl");
- transaction.newMXBeanProxy(nameCreated, PCEPSessionProposalFactoryImplModuleMXBean.class);
- return nameCreated;
- }
-
- private static ObjectName createDispatcherInstance(final ConfigTransactionJMXClient transaction, final Integer maxUnknownMessages,
- final Tls tls) throws Exception {
- final ObjectName objName = createDispatcherInstance(transaction, maxUnknownMessages);
- final PCEPDispatcherImplModuleMXBean mxBean = transaction.newMXBeanProxy(objName, PCEPDispatcherImplModuleMXBean.class);
- mxBean.setTls(tls);
- return objName;
- }
-
- private static ObjectName createExtensionsInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(EXTENSION_FACTORYNAME, EXTENSION_INSTANCE_NAME);
- transaction.newMXBeanProxy(nameCreated, SimplePCEPExtensionProviderContextModuleMXBean.class);
-
- return nameCreated;
- }
-
- private static ObjectName createThreadGroupInstance(final ConfigTransactionJMXClient transaction, final Integer threadCount,
- final String instanceName) throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(THREADGROUP_FACTORY_NAME, instanceName);
- final NettyThreadgroupModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NettyThreadgroupModuleMXBean.class);
- mxBean.setThreadCount(threadCount);
- return nameCreated;
- }
-
- private static Tls createTls(final String certificatePassword, final String keystore, final String keystorePassword,
- final PathType keystorePathType, final StoreType keystoreType, final String truststore,
- final String truststorePassword, final PathType truststorePathType, final StoreType truststoreType) {
- final Tls tls = new Tls();
- tls.setCertificatePassword(certificatePassword);
- tls.setKeystore(keystore);
- tls.setKeystorePassword(keystorePassword);
- tls.setKeystorePathType(keystorePathType);
- tls.setKeystoreType(keystoreType);
- tls.setTruststore(truststore);
- tls.setTruststorePassword(truststorePassword);
- tls.setTruststorePathType(truststorePathType);
- tls.setTruststoreType(truststoreType);
- return tls;
- }
-
-}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.GlobalEventExecutor;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
import org.opendaylight.protocol.pcep.impl.spi.Util;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.TlsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr;
this.serverSession = new DefaultPCEPSessionNegotiator(new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE),
this.channel, this.listener, (short) 1, 20, localPrefs);
this.tlsSessionNegotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE),
- this.channel, this.listener, (short) 1, 20, localPrefs, new Tls());
+ this.channel, this.listener, (short) 1, 20, localPrefs, new TlsBuilder().build());
}
/**
package org.opendaylight.protocol.pcep.impl;
import static org.junit.Assert.assertNotNull;
-
import javax.net.ssl.SSLContext;
import org.junit.Test;
-import org.opendaylight.controller.config.yang.pcep.impl.Tls;
import org.opendaylight.protocol.pcep.impl.tls.SslContextFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.PathType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.impl.rev130627.StoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PathType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.StoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.Tls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.TlsBuilder;
public class SslContextFactoryTest {
}
public static Tls createTlsConfig() {
- final Tls tlsConfig = new Tls();
- tlsConfig.setCertificatePassword("opendaylight");
- tlsConfig.setKeystore("/exemplary-ctlKeystore");
- tlsConfig.setKeystorePassword("opendaylight");
- tlsConfig.setKeystorePathType(PathType.CLASSPATH);
- tlsConfig.setKeystoreType(StoreType.JKS);
- tlsConfig.setTruststore("/exemplary-ctlTrustStore");
- tlsConfig.setTruststorePassword("opendaylight");
- tlsConfig.setTruststorePathType(PathType.CLASSPATH);
- tlsConfig.setTruststoreType(StoreType.JKS);
- return tlsConfig;
+ return new TlsBuilder().setCertificatePassword("opendaylight").setKeystore("/exemplary-ctlKeystore")
+ .setKeystorePassword("opendaylight").setKeystorePathType(PathType.CLASSPATH)
+ .setKeystoreType(StoreType.JKS).setTruststore("/exemplary-ctlTrustStore")
+ .setTruststorePassword("opendaylight").setTruststorePathType(PathType.CLASSPATH)
+ .setTruststoreType(StoreType.JKS).build();
}
-
}
<artifactId>concepts</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
</dependency>
<!--test dependencies -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-manager</artifactId>
- <type>test-jar</type>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-manager</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-util</artifactId>
- </dependency>
</dependencies>
<build>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
+++ /dev/null
-/*
- * 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
- */
-/**
- * Generated file
-
- * Generated from: yang module name: config-pcep-spi yang module local name: pcep-extensions-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Mon Nov 18 14:32:53 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.pcep.spi;
-
-import com.google.common.reflect.AbstractInvocationHandler;
-import com.google.common.reflect.Reflection;
-import java.lang.reflect.Method;
-import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
-import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
-import org.osgi.framework.BundleContext;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public final class SimplePCEPExtensionProviderContextModule extends AbstractSimplePCEPExtensionProviderContextModule {
- private BundleContext bundleContext;
-
- public SimplePCEPExtensionProviderContextModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public SimplePCEPExtensionProviderContextModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final SimplePCEPExtensionProviderContextModule oldModule, final java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public AutoCloseable createInstance() {
- final WaitingServiceTracker<PCEPExtensionProviderContext> tracker =
- WaitingServiceTracker.create(PCEPExtensionProviderContext.class, bundleContext);
- final PCEPExtensionProviderContext service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
-
- return Reflection.newProxy(AutoCloseablePCEPExtensionProviderContext.class, new AbstractInvocationHandler() {
- @Override
- protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
- if (method.getName().equals("close")) {
- tracker.close();
- return null;
- } else {
- return method.invoke(service, args);
- }
- }
- });
- }
-
- void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- private static interface AutoCloseablePCEPExtensionProviderContext extends PCEPExtensionProviderContext, AutoCloseable {
- }
-}
+++ /dev/null
-/*
- * 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
- */
-/**
- * Generated file
-
- * Generated from: yang module name: config-pcep-spi yang module local name: pcep-extensions-impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Mon Nov 18 14:32:53 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.pcep.spi;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.osgi.framework.BundleContext;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public class SimplePCEPExtensionProviderContextModuleFactory extends AbstractSimplePCEPExtensionProviderContextModuleFactory {
- @Override
- public SimplePCEPExtensionProviderContextModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
- SimplePCEPExtensionProviderContextModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
- SimplePCEPExtensionProviderContextModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
- oldInstance, bundleContext);
- module.setBundleContext(bundleContext);
- return module;
- }
-
- @Override
- public SimplePCEPExtensionProviderContextModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
- BundleContext bundleContext) {
- SimplePCEPExtensionProviderContextModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
- module.setBundleContext(bundleContext);
- return module;
- }
-}
+++ /dev/null
-// vi: set smarttab et sw=4 tabstop=4:
-module odl-pcep-spi-cfg {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:spi";
- prefix "spi";
-
- import config { prefix config; revision-date 2013-04-05; }
-
- organization "Cisco Systems, Inc.";
-
- contact "Robert Varga <rovarga@cisco.com>";
-
- description
- "This module contains the base YANG definitions for
- PCEP SPI module.
-
- 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-11-15" {
- description
- "Initial revision";
- }
-
- identity consumer-extensions {
- description
- "Service representing a PCEP parser extension registry. Extension
- consumers have this service injected.";
-
- base "config:service-type";
- config:java-class "org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext";
- }
-
- identity extensions {
- description
- "Service representing a PCEP parser extension registry. Extension
- providers have this service injected for registration.";
-
- base "consumer-extensions";
- config:java-class "org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext";
- }
-
- identity extension {
- description
- "Service representing a PCEP parser extension.";
-
- base "config:service-type";
- config:java-class "org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator";
- config:disable-osgi-service-registration;
- }
-
- identity pcep-extensions-impl {
- base config:module-type;
- config:provided-service extensions;
- config:java-name-prefix SimplePCEPExtensionProviderContext;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case pcep-extensions-impl {
- when "/config:modules/config:module/config:type = 'pcep-extensions-impl'";
- }
- }
-}
-
import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.pcep.topology.provider.PCEPTopologyProvider;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.protocol.concepts.KeyMapping;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleTest.createDispatcherInstance;
+import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
+import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
public void setUp() throws Exception {
super.setUp();
- setupMockService(PCEPExtensionProviderContext.class, new SimplePCEPExtensionProviderContext());
- setupMockService(PCEPSessionProposalFactory.class, new BasePCEPSessionProposalFactory(120, 30,
- Collections.emptyList()));
+ SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
+ setupMockService(PCEPExtensionProviderContext.class, extContext);
+ BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
+ Collections.emptyList());
+ setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
+ NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
+ setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
+ new DefaultPCEPSessionNegotiatorFactory(proposalFactory, 5), eventLoopGroup, eventLoopGroup));
}
@Test
public void testCreateBean() throws Exception {
final CommitStatus status = createInstance(false);
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 17, 0, 0);
+ assertStatus(status, 13, 0, 0);
}
@Test
assertBeanCount(1, FACTORY_NAME);
final CommitStatus status = transaction.commit();
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 17);
+ assertStatus(status, 0, 0, 13);
}
@Test
mxBean.setTopologyId(new TopologyId("new-pcep-topology"));
final CommitStatus status = transaction.commit();
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 1, 16);
+ assertStatus(status, 0, 1, 12);
}
private CommitStatus createInstance(final String listenAddress, final PortNumber listenPort,
final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
mxBean.setDataProvider(dataBrokerON);
- mxBean.setDispatcher(createDispatcherInstance(transaction, 5));
+ mxBean.setDispatcher(createDispatcherInstance(transaction));
mxBean.setListenAddress(new IpAddress(LISTEN_ADDRESS.toCharArray()));
mxBean.setListenPort(getRandomPortNumber());
return objectName;
}
+ public static ObjectName createDispatcherInstance(final ConfigTransactionJMXClient transaction)
+ throws Exception {
+ final ObjectName nameCreated = transaction.createModule(PCEPDispatcherImplModuleFactory.NAME, "pcep-dispatcher-impl");
+ transaction.newMXBeanProxy(nameCreated, PCEPDispatcherImplModuleMXBean.class);
+ return nameCreated;
+ }
+
private ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction, final String listenAddress,
final PortNumber listenPort, final TopologyId topologyId, final boolean addMD5) throws Exception {
final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
mxBean.setDataProvider(asyncDataBrokerON);
- mxBean.setDispatcher(createDispatcherInstance(transaction, 5));
+ mxBean.setDispatcher(createDispatcherInstance(transaction));
if (addMD5) {
// create 1 client
final List<ModuleFactory> moduleFactories = super.getModuleFactories();
moduleFactories.add(new PCEPTopologyProviderModuleFactory());
moduleFactories.add(new PCEPDispatcherImplModuleFactory());
- moduleFactories.add(new PCEPSessionProposalFactoryImplModuleFactory());
moduleFactories.add(new NettyThreadgroupModuleFactory());
- moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
return moduleFactories;
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Collections;
import java.util.List;
import javax.management.ObjectName;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleFactory;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleMXBean;
import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleTest;
import org.opendaylight.controller.config.yang.pcep.topology.provider.Stateful07TopologySessionListenerModuleFactory;
import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
+import org.opendaylight.protocol.pcep.PCEPDispatcher;
import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
public void setUp() throws Exception {
super.setUp();
- setupMockService(PCEPExtensionProviderContext.class, new SimplePCEPExtensionProviderContext());
- setupMockService(PCEPSessionProposalFactory.class, new BasePCEPSessionProposalFactory(120, 30,
- Collections.emptyList()));
+ SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
+ setupMockService(PCEPExtensionProviderContext.class, extContext);
+ BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
+ Collections.emptyList());
+ setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
+ NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
+ setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
+ new DefaultPCEPSessionNegotiatorFactory(proposalFactory, 5), eventLoopGroup, eventLoopGroup));
}
@Test
public void testCreateBean() throws Exception {
final CommitStatus status = createInstance();
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 18, 0, 0);
+ assertStatus(status, 14, 0, 0);
}
@Test
assertBeanCount(1, FACTORY_NAME);
final CommitStatus status = transaction.commit();
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 18);
+ assertStatus(status, 0, 0, 14);
}
@Test
mxBean.setTopologyId(new TopologyId("new-pcep-topology"));
final CommitStatus status = transaction.commit();
assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 1, 17);
+ assertStatus(status, 0, 1, 13);
}
private CommitStatus createInstance(final TopologyId topologyId) throws Exception {
moduleFactories.add(new PCEPTunnelTopologyProviderModuleFactory());
moduleFactories.add(new PCEPTopologyProviderModuleFactory());
moduleFactories.add(new PCEPDispatcherImplModuleFactory());
- moduleFactories.add(new PCEPSessionProposalFactoryImplModuleFactory());
moduleFactories.add(new NettyThreadgroupModuleFactory());
- moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
return moduleFactories;
}