Search in sources :

Example 1 with AvailableCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability in project netconf by opendaylight.

the class NetconfDeviceTopologyAdapter method buildDataForNetconfNode.

private NetconfNode buildDataForNetconfNode(final ConnectionStatus connectionStatus, final NetconfDeviceCapabilities capabilities, final LogicalDatastoreType dsType, final NetconfNode node) {
    List<AvailableCapability> capabilityList = new ArrayList<>();
    capabilityList.addAll(capabilities.getNonModuleBasedCapabilities());
    capabilityList.addAll(capabilities.getResolvedCapabilities());
    final AvailableCapabilitiesBuilder avCapabalitiesBuilder = new AvailableCapabilitiesBuilder();
    avCapabalitiesBuilder.setAvailableCapability(capabilityList);
    return new NetconfNodeBuilder().setHost(id.getHost()).setPort(new PortNumber(Uint16.valueOf(id.getAddress().getPort()))).setConnectionStatus(connectionStatus).setAvailableCapabilities(avCapabalitiesBuilder.build()).setUnavailableCapabilities(unavailableCapabilities(capabilities.getUnresolvedCapabilites())).build();
}
Also used : NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) ArrayList(java.util.ArrayList) AvailableCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability) AvailableCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)

Example 2 with AvailableCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability in project netconf by opendaylight.

the class NetconfDeviceTopologyAdapter method buildDataForNetconfClusteredNode.

private NetconfNode buildDataForNetconfClusteredNode(final boolean up, final String masterNodeAddress, final NetconfDeviceCapabilities capabilities) {
    List<AvailableCapability> capabilityList = new ArrayList<>();
    capabilityList.addAll(capabilities.getNonModuleBasedCapabilities());
    capabilityList.addAll(capabilities.getResolvedCapabilities());
    final AvailableCapabilitiesBuilder avCapabalitiesBuilder = new AvailableCapabilitiesBuilder();
    avCapabalitiesBuilder.setAvailableCapability(capabilityList);
    final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder().setHost(id.getHost()).setPort(new PortNumber(Uint16.valueOf(id.getAddress().getPort()))).setConnectionStatus(up ? ConnectionStatus.Connected : ConnectionStatus.Connecting).setAvailableCapabilities(avCapabalitiesBuilder.build()).setUnavailableCapabilities(unavailableCapabilities(capabilities.getUnresolvedCapabilites())).setClusteredConnectionStatus(new ClusteredConnectionStatusBuilder().setNetconfMasterNode(masterNodeAddress).build());
    return netconfNodeBuilder.build();
}
Also used : NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) ClusteredConnectionStatusBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatusBuilder) ArrayList(java.util.ArrayList) AvailableCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability) AvailableCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)

Example 3 with AvailableCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability in project netconf by opendaylight.

the class NetconfCommandsImplTest method getNetconfNode.

private static Node getNetconfNode(final String nodeIdent, final String ip, final int portNumber, final NetconfNodeConnectionStatus.ConnectionStatus cs, final String notificationCapabilityPrefix) {
    final Host host = HostBuilder.getDefaultInstance(ip);
    final PortNumber port = new PortNumber(Uint16.valueOf(portNumber));
    final List<AvailableCapability> avCapList = new ArrayList<>();
    avCapList.add(new AvailableCapabilityBuilder().setCapabilityOrigin(AvailableCapability.CapabilityOrigin.UserDefined).setCapability(notificationCapabilityPrefix + "_availableCapabilityString1").build());
    final AvailableCapabilities avCaps = new AvailableCapabilitiesBuilder().setAvailableCapability(avCapList).build();
    final NodeId nodeId = new NodeId(nodeIdent);
    final NodeKey nk = new NodeKey(nodeId);
    return new NodeBuilder().withKey(nk).setNodeId(nodeId).addAugmentation(new NetconfNodeBuilder().setConnectionStatus(cs).setHost(host).setPort(port).setAvailableCapabilities(avCaps).build()).build();
}
Also used : NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) AvailableCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) AvailableCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) AvailableCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability) AvailableCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder) 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) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 4 with AvailableCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability in project lighty-netconf-simulator by PANTHEONtech.

the class NetworkTopologyServiceImpl method addNodeIntoTopology.

@Override
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
public ListenableFuture<RpcResult<AddNodeIntoTopologyOutput>> addNodeIntoTopology(final AddNodeIntoTopologyInput input) {
    Preconditions.checkNotNull(this.dataBrokerService);
    LOG.info("Adding node to topology {}", input.getTopologyId());
    final SettableFuture<RpcResult<AddNodeIntoTopologyOutput>> result = SettableFuture.create();
    this.executor.submit(new Callable<RpcResult<AddNodeIntoTopologyOutput>>() {

        @Override
        public RpcResult<AddNodeIntoTopologyOutput> call() throws Exception {
            final WriteTransaction writeTx = NetworkTopologyServiceImpl.this.dataBrokerService.newWriteOnlyTransaction();
            final TopologyId topologyId = input.getTopologyId();
            final Collection<Node> nodeCollection = input.nonnullNode().values();
            final Map<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeConfigMap = new HashMap<>();
            final Map<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeOperMap = new HashMap<>();
            for (final Node node : nodeCollection) {
                NetconfNode netconfNode = new NetconfNodeBuilder().setHost(node.getHost()).setPort(node.getPort()).setCredentials(node.getCredentials()).setKeepaliveDelay(node.getKeepaliveDelay()).setSchemaless(node.getSchemaless()).setTcpOnly(node.getTcpOnly()).build();
                final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node nConfig = createNetworkTopologyNode(node, netconfNode);
                final List<AvailableCapability> availableCapabilities = new ArrayList<>();
                for (final Module m : NetworkTopologyServiceImpl.this.effectiveModelContext.getModules()) {
                    final Revision revision = m.getRevision().orElse(Revision.of("2017-01-01"));
                    final AvailableCapability ac = new AvailableCapabilityBuilder().setCapabilityOrigin(AvailableCapability.CapabilityOrigin.DeviceAdvertised).setCapability(String.format("(%s?revision=%s)%s", m.getNamespace(), revision, m.getName())).build();
                    availableCapabilities.add(ac);
                }
                netconfNode = new NetconfNodeBuilder().setConnectionStatus(NetconfNodeConnectionStatus.ConnectionStatus.Connected).setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().build()).setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(availableCapabilities).build()).setHost(node.getHost()).setPort(node.getPort()).build();
                final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node nOper = createNetworkTopologyNode(node, netconfNode);
                nodeConfigMap.put(nConfig.key(), nConfig);
                nodeOperMap.put(nOper.key(), nOper);
            }
            Topology topology = new TopologyBuilder().setTopologyId(topologyId).setNode(nodeConfigMap).build();
            final InstanceIdentifier<Topology> tii = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, topology.key()).build();
            writeTx.merge(LogicalDatastoreType.CONFIGURATION, tii, topology);
            topology = new TopologyBuilder().setTopologyId(topologyId).setNode(nodeOperMap).build();
            writeTx.merge(LogicalDatastoreType.OPERATIONAL, tii, topology);
            writeTx.commit().get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
            final AddNodeIntoTopologyOutput addNodeIntoTopologyOutput = new AddNodeIntoTopologyOutputBuilder().build();
            final RpcResult<AddNodeIntoTopologyOutput> rpcResult = RpcResultBuilder.success(addNodeIntoTopologyOutput).build();
            result.set(rpcResult);
            return rpcResult;
        }
    });
    return result;
}
Also used : Preconditions(com.google.common.base.Preconditions) NetworkTopologyBuilder(org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.get.topologies.output.NetworkTopologyBuilder) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) Node(org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) AddNodeIntoTopologyOutput(org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.AddNodeIntoTopologyOutput) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) AvailableCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapabilityBuilder) AvailableCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder) AddNodeIntoTopologyOutputBuilder(org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.AddNodeIntoTopologyOutputBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) List(java.util.List) ArrayList(java.util.ArrayList) AvailableCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) 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) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) UnavailableCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilitiesBuilder) Revision(org.opendaylight.yangtools.yang.common.Revision) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Collection(java.util.Collection) Module(org.opendaylight.yangtools.yang.model.api.Module) Map(java.util.Map) HashMap(java.util.HashMap) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 5 with AvailableCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability in project netconf by opendaylight.

the class NetconfCommandsImpl method showDevice.

@Override
public Map<String, Map<String, List<String>>> showDevice(final String deviceId) {
    final Map<String, Map<String, List<String>>> device = new HashMap<>();
    final Node node = NetconfConsoleUtils.getNetconfNodeFromId(deviceId, dataBroker);
    if (node != null) {
        final NetconfNode netconfNode = node.augmentation(NetconfNode.class);
        final Map<String, List<String>> attributes = new HashMap<>();
        attributes.put(NetconfConsoleConstants.NETCONF_ID, List.of(node.getNodeId().getValue()));
        attributes.put(NetconfConsoleConstants.NETCONF_IP, List.of(netconfNode.getHost().getIpAddress().getIpv4Address().getValue()));
        attributes.put(NetconfConsoleConstants.NETCONF_PORT, List.of(netconfNode.getPort().getValue().toString()));
        attributes.put(NetconfConsoleConstants.STATUS, List.of(netconfNode.getConnectionStatus().name()));
        if (netconfNode.getConnectionStatus().equals(NetconfNodeConnectionStatus.ConnectionStatus.Connected)) {
            attributes.put(NetconfConsoleConstants.AVAILABLE_CAPABILITIES, netconfNode.getAvailableCapabilities().getAvailableCapability().stream().map(AvailableCapability::getCapability).collect(Collectors.toList()));
        } else {
            attributes.put(NetconfConsoleConstants.AVAILABLE_CAPABILITIES, List.of(""));
        }
        device.put(node.getNodeId().getValue(), attributes);
    }
    return device;
}
Also used : HashMap(java.util.HashMap) 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) List(java.util.List) AvailableCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AvailableCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 Collection (java.util.Collection)3 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)3 NetconfNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder)3 AvailableCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilitiesBuilder)3 Revision (org.opendaylight.yangtools.yang.common.Revision)3 Module (org.opendaylight.yangtools.yang.model.api.Module)3 HashMultimap (com.google.common.collect.HashMultimap)2 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 Futures (com.google.common.util.concurrent.Futures)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 SettableFuture (com.google.common.util.concurrent.SettableFuture)2 IOException (java.io.IOException)2