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();
}
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();
}
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();
}
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;
}
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;
}
Aggregations