Search in sources :

Example 1 with DefaultYangParserFactory

use of org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory in project lighty-netconf-simulator by PANTHEONtech.

the class NetconfDeviceServicesImpl method createAdapterContext.

private AdapterContext createAdapterContext(Collection<YangModuleInfo> moduleInfos) {
    final YangParserFactory yangParserFactory = new DefaultYangParserFactory();
    ModuleInfoSnapshotResolver snapshotResolver = new ModuleInfoSnapshotResolver("netconf-simulator", yangParserFactory);
    snapshotResolver.registerModuleInfos(moduleInfos);
    ModuleInfoSnapshot moduleInfoSnapshot = snapshotResolver.takeSnapshot();
    final BindingRuntimeGenerator bindingRuntimeGenerator = new DefaultBindingRuntimeGenerator();
    final BindingRuntimeTypes bindingRuntimeTypes = bindingRuntimeGenerator.generateTypeMapping(moduleInfoSnapshot.getEffectiveModelContext());
    final DefaultBindingRuntimeContext bindingRuntimeContext = new DefaultBindingRuntimeContext(bindingRuntimeTypes, moduleInfoSnapshot);
    final BindingCodecContext bindingCodecContext = new BindingCodecContext(bindingRuntimeContext);
    return new ConstantAdapterContext(bindingCodecContext);
}
Also used : ModuleInfoSnapshot(org.opendaylight.mdsal.binding.runtime.api.ModuleInfoSnapshot) ConstantAdapterContext(org.opendaylight.mdsal.binding.dom.adapter.ConstantAdapterContext) DefaultBindingRuntimeGenerator(org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator) BindingCodecContext(org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext) BindingRuntimeTypes(org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) ModuleInfoSnapshotResolver(org.opendaylight.mdsal.binding.runtime.spi.ModuleInfoSnapshotResolver) DefaultBindingRuntimeContext(org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext) YangParserFactory(org.opendaylight.yangtools.yang.parser.api.YangParserFactory) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) DefaultBindingRuntimeGenerator(org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator) BindingRuntimeGenerator(org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator)

Example 2 with DefaultYangParserFactory

use of org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory in project netconf by opendaylight.

the class MountPointEndToEndTest method setUp.

@Before
public void setUp() throws Exception {
    deleteCacheDir();
    resourceManager = new DefaultSchemaResourceManager(new DefaultYangParserFactory(), TEST_ROOT_DIRECTORY, TEST_DEFAULT_SUBDIR);
    topModuleInfo = BindingReflections.getModuleInfo(Top.class);
    deviceSchemaContext = BindingRuntimeHelpers.createEffectiveModel(Top.class);
    deviceRpcService.onModelContextUpdated(deviceSchemaContext);
    putTopRpcSchemaPath = findRpcDefinition("put-top").getQName();
    getTopRpcSchemaPath = findRpcDefinition("get-top").getQName();
    deviceRpcService.getRpcProviderService().registerRpcImplementation(topRpcImplementation, DOMRpcIdentifier.create(putTopRpcSchemaPath), DOMRpcIdentifier.create(getTopRpcSchemaPath));
    setupMaster();
    setupSlave();
    yangNodeInstanceId = bindingToNormalized.toYangInstanceIdentifier(NODE_INSTANCE_ID);
    doReturn(mock(ReconnectFuture.class)).when(mockClientDispatcher).createReconnectingClient(any());
    LOG.info("****** Setup complete");
}
Also used : Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) ReconnectFuture(org.opendaylight.netconf.nettyutil.ReconnectFuture) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) Before(org.junit.Before)

Example 3 with DefaultYangParserFactory

use of org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory in project netconf by opendaylight.

the class RemoteDeviceConnectorImplTest method testKeapAliveFacade.

@SuppressWarnings("unchecked")
@Test
public void testKeapAliveFacade() {
    final Credentials credentials = new LoginPasswordBuilder().setPassword("admin").setUsername("admin").build();
    final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))).setPort(new PortNumber(Uint16.valueOf(9999))).setReconnectOnChangedSchema(true).setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)).setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100)).setSchemaless(false).setTcpOnly(false).setCredentials(credentials).setKeepaliveDelay(Uint32.ONE).build();
    final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(netconfNode).build();
    builder.setSchemaResourceDTO(new DefaultSchemaResourceManager(new DefaultYangParserFactory()).getSchemaResources(netconfNode, "foo"));
    final RemoteDeviceConnectorImpl remoteDeviceConnection = new RemoteDeviceConnectorImpl(builder.build(), remoteDeviceId, deviceActionFactory);
    final RemoteDeviceHandler<NetconfSessionPreferences> salFacade = mock(RemoteDeviceHandler.class);
    final NetconfConnectorDTO connectorDTO = remoteDeviceConnection.createDeviceCommunicator(NODE_ID, netconfNode, salFacade);
    assertTrue(connectorDTO.getFacade() instanceof KeepaliveSalFacade);
}
Also used : NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) KeepaliveSalFacade(org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) NetconfConnectorDTO(org.opendaylight.netconf.topology.spi.NetconfConnectorDTO) LoginPasswordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) Credentials(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 4 with DefaultYangParserFactory

use of org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory in project netconf by opendaylight.

the class YangLibProviderTest method setUp.

@Before
public void setUp() {
    try {
        if (CACHE_DIR.exists()) {
            FileUtils.cleanDirectory(CACHE_DIR);
        }
    } catch (IOException e) {
    // Ignore
    }
    final YanglibConfig yanglibConfig = new YanglibConfigBuilder().setBindingAddr("www.fake.com").setBindingPort(Uint32.valueOf(300)).setCacheFolder(CACHE_DIR.getAbsolutePath()).build();
    yangLibProvider = new YangLibProvider(yanglibConfig, dataBroker, new DefaultYangParserFactory());
}
Also used : YanglibConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) IOException(java.io.IOException) YanglibConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfigBuilder) Before(org.junit.Before)

Example 5 with DefaultYangParserFactory

use of org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory in project netconf by opendaylight.

the class NetconfTopologyManagerTest method setUp.

@Before
public void setUp() throws Exception {
    AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest() {

        @Override
        protected Set<YangModuleInfo> getModuleInfos() throws Exception {
            return ImmutableSet.of(BindingReflections.getModuleInfo(NetworkTopology.class), BindingReflections.getModuleInfo(Topology.class));
        }
    };
    dataBrokerTest.setup();
    dataBroker = spy(dataBrokerTest.getDataBroker());
    final DOMRpcProviderService rpcProviderRegistry = mock(DOMRpcProviderService.class);
    final ScheduledThreadPool keepaliveExecutor = mock(ScheduledThreadPool.class);
    final DOMActionProviderService actionProviderRegistry = mock(DOMActionProviderService.class);
    final ThreadPool processingThreadPool = mock(ThreadPool.class);
    final ExecutorService processingService = mock(ExecutorService.class);
    doReturn(processingService).when(processingThreadPool).getExecutor();
    final ActorSystemProvider actorSystemProvider = mock(ActorSystemProvider.class);
    final EventExecutor eventExecutor = mock(EventExecutor.class);
    final NetconfClientDispatcher clientDispatcher = mock(NetconfClientDispatcher.class);
    final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
    final AAAEncryptionService encryptionService = mock(AAAEncryptionService.class);
    final DeviceActionFactory deviceActionFactory = mock(DeviceActionFactory.class);
    final RpcProviderService rpcProviderService = mock(RpcProviderService.class);
    final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build();
    netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, rpcProviderRegistry, actionProviderRegistry, clusterSingletonServiceProvider, keepaliveExecutor, processingThreadPool, actorSystemProvider, eventExecutor, clientDispatcher, TOPOLOGY_ID, config, mountPointService, encryptionService, rpcProviderService, deviceActionFactory, new DefaultSchemaResourceManager(new DefaultYangParserFactory())) {

        @Override
        protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory deviceActionFactory) {
            assertEquals(ACTOR_RESPONSE_WAIT_TIME.toJava(), actorResponseWaitTime.duration().toSeconds());
            return Objects.requireNonNull(mockContextMap.get(setup.getInstanceIdentifier()), "No mock context for " + setup.getInstanceIdentifier()).apply(setup);
        }
    };
    doNothing().when(mockListenerReg).close();
    doReturn(mockListenerReg).when(dataBroker).registerDataTreeChangeListener(any(), any());
}
Also used : RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config) ThreadPool(org.opendaylight.controller.config.threadpool.ThreadPool) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) ActorSystemProvider(org.opendaylight.controller.cluster.ActorSystemProvider) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) AAAEncryptionService(org.opendaylight.aaa.encrypt.AAAEncryptionService) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Timeout(akka.util.Timeout) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) EventExecutor(io.netty.util.concurrent.EventExecutor) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) ExecutorService(java.util.concurrent.ExecutorService) NetconfClientDispatcher(org.opendaylight.netconf.client.NetconfClientDispatcher) Before(org.junit.Before)

Aggregations

DefaultYangParserFactory (org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory)5 Before (org.junit.Before)3 DefaultSchemaResourceManager (org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager)3 Timeout (akka.util.Timeout)1 EventExecutor (io.netty.util.concurrent.EventExecutor)1 IOException (java.io.IOException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.Test)1 AAAEncryptionService (org.opendaylight.aaa.encrypt.AAAEncryptionService)1 ActorSystemProvider (org.opendaylight.controller.cluster.ActorSystemProvider)1 ScheduledThreadPool (org.opendaylight.controller.config.threadpool.ScheduledThreadPool)1 ThreadPool (org.opendaylight.controller.config.threadpool.ThreadPool)1 RpcProviderService (org.opendaylight.mdsal.binding.api.RpcProviderService)1 ConstantAdapterContext (org.opendaylight.mdsal.binding.dom.adapter.ConstantAdapterContext)1 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)1 BindingCodecContext (org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext)1 DefaultBindingRuntimeGenerator (org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator)1 BindingRuntimeGenerator (org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator)1 BindingRuntimeTypes (org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes)1 DefaultBindingRuntimeContext (org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext)1