use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class TepCommandHelper method showState.
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showState(Collection<StateTunnelList> tunnelLists, boolean tunnelMonitorEnabled, CommandSession session) throws TepException {
if (tunnelLists == null || tunnelLists.isEmpty()) {
handleError("No Internal Tunnels Exist", session);
return;
}
if (!tunnelMonitorEnabled) {
if (session != null) {
session.getConsole().println("Tunnel Monitoring is Off");
}
}
String displayFormat = "%-16s %-16s %-16s %-16s %-16s %-10s %-10s";
System.out.println(String.format(displayFormat, "Tunnel Name", "Source-DPN", "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
System.out.println("-----------------------------------------------------------------------------------------" + "--------------------------------------------");
for (StateTunnelList tunnelInst : tunnelLists) {
// Display only the internal tunnels
if (tunnelInst.getDstInfo().getTepDeviceType().equals(TepTypeInternal.class)) {
String tunnelInterfaceName = tunnelInst.getTunnelInterfaceName();
LOG.trace("tunnelInterfaceName::: {}", tunnelInterfaceName);
String tunnelState = ITMConstants.TUNNEL_STATE_UNKNOWN;
if (tunnelInst.getOperState() == TunnelOperStatus.Up) {
tunnelState = ITMConstants.TUNNEL_STATE_UP;
} else if (tunnelInst.getOperState() == TunnelOperStatus.Down) {
tunnelState = ITMConstants.TUNNEL_STATE_DOWN;
}
Class<? extends TunnelTypeBase> tunType = tunnelInst.getTransportType();
String tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
if (tunType.equals(TunnelTypeVxlan.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
} else if (tunType.equals(TunnelTypeGre.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_GRE;
} else if (tunType.equals(TunnelTypeMplsOverGre.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_MPLSoGRE;
} else if (tunType.equals(TunnelTypeLogicalGroup.class)) {
tunnelType = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
}
System.out.println(String.format(displayFormat, tunnelInst.getTunnelInterfaceName(), tunnelInst.getSrcInfo().getTepDeviceId(), tunnelInst.getDstInfo().getTepDeviceId(), new String(tunnelInst.getSrcInfo().getTepIp().getValue()), new String(tunnelInst.getDstInfo().getTepIp().getValue()), tunnelState, tunnelType));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class TepCommandHelper method validateForDuplicates.
/**
* Validate for duplicates.
*
* @param inputVtep
* the input vtep
* @param transportZone
* the transport zone
*/
public void validateForDuplicates(Vteps inputVtep, String transportZone) {
Map<String, TransportZone> allTransportZonesAsMap = getAllTransportZonesAsMap();
boolean isConfiguredTepGreType = isGreTunnelType(transportZone, allTransportZonesAsMap);
// Checking for duplicates in local cache
for (Entry<String, Map<SubnetObject, List<Vteps>>> entry : transportZonesHashMap.entrySet()) {
String tz = entry.getKey();
boolean isGreType = isGreTunnelType(tz, allTransportZonesAsMap);
Map<SubnetObject, List<Vteps>> subVtepMapTemp = entry.getValue();
for (List<Vteps> vtepList : subVtepMapTemp.values()) {
validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
}
}
// Checking for duplicates in config DS
for (TransportZone tz : allTransportZonesAsMap.values()) {
boolean isGreType = false;
if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
isGreType = true;
}
for (Subnets sub : ItmUtils.emptyIfNull(tz.getSubnets())) {
List<Vteps> vtepList = sub.getVteps();
validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project netvirt by opendaylight.
the class ElanDpnToTransportZoneListener method add.
@Override
public void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
// Proceed only if "auto-config-transport-zones = TRUE"
if (!useTransportZone) {
return;
}
LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
Uint64 dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orElse(null))) {
return;
}
transportZoneNotificationUtil.updateTransportZone(elanInstanceName, dpId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project bgpcep by opendaylight.
the class NeighborStateCliUtilsTest method testFullNeighborStateCli.
@Test
public void testFullNeighborStateCli() throws IOException {
final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().addAugmentation(new NeighborAfiSafiStateAugmentationBuilder().setActive(Boolean.TRUE).setPrefixes(new PrefixesBuilder().setInstalled(Uint32.ONE).setReceived(Uint32.ONE).setSent(Uint32.TWO).build()).build()).build()).build();
final StateBuilder stateBuilder = new StateBuilder().addAugmentation(new NeighborStateAugmentationBuilder().setSupportedCapabilities(Collections.singletonList(ADDPATHS.class)).setSessionState(BgpNeighborState.SessionState.ACTIVE).build());
final Received received = new ReceivedBuilder().setNOTIFICATION(Uint64.ONE).setUPDATE(Uint64.TEN).build();
final Sent sent = new SentBuilder().setNOTIFICATION(Uint64.TEN).setUPDATE(Uint64.ONE).build();
stateBuilder.addAugmentation(new BgpNeighborStateAugmentationBuilder().setMessages(new MessagesBuilder().setReceived(received).setSent(sent).build()).build());
final Transport transport = new TransportBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.StateBuilder().addAugmentation(new NeighborTransportStateAugmentationBuilder().setRemoteAddress(NEIGHBOR_IP_ADDRESS).setLocalPort(new PortNumber(Uint16.valueOf(1234))).setRemotePort(new PortNumber(Uint16.valueOf(4321))).build()).build()).build();
final Timers timers = new TimersBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.StateBuilder().addAugmentation(new NeighborTimersStateAugmentationBuilder().setNegotiatedHoldTime(BigDecimal.TEN).setUptime(new Timeticks(Uint32.valueOf(600))).build()).build()).build();
final Neighbor neighbor = new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4"))).setState(stateBuilder.build()).setAfiSafis(new AfiSafisBuilder().setAfiSafi(Map.of(afiSafi.key(), afiSafi)).build()).setTransport(transport).setTimers(timers).build();
NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
final String expected = Resources.toString(getClass().getClassLoader().getResource("neighbor.txt"), StandardCharsets.UTF_8);
assertEquals(expected, this.output.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class CloudscalerRpcServiceImpl method scaleinComputesTepDelete.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public ListenableFuture<RpcResult<ScaleinComputesTepDeleteOutput>> scaleinComputesTepDelete(ScaleinComputesTepDeleteInput input) {
ReadTransaction readTx = this.dataBroker.newReadOnlyTransaction();
SettableFuture<RpcResult<ScaleinComputesTepDeleteOutput>> ft = SettableFuture.create();
Optional<TransportZones> tz;
try {
tz = readTx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(TransportZones.class)).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Cloudscaler Failed to read the transport zone {}", e.getMessage());
ft.set(RpcResultBuilder.<ScaleinComputesTepDeleteOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Failed to read the transport zone " + e.getMessage()).build());
return ft;
} finally {
readTx.close();
}
try {
for (String computeName : input.getScaleinComputeNames()) {
ComputeNode computeNode = null;
try {
computeNode = computeNodeManager.getComputeNodeFromName(computeName);
if (computeNode == null) {
LOG.warn("Cloudscaler Could not find the compute for tep delete {}", computeName);
ft.set(RpcResultBuilder.<ScaleinComputesTepDeleteOutput>success().build());
return ft;
}
} catch (ReadFailedException e) {
LOG.error("Cloudscaler Failed to read the compute node {}", e.getMessage());
ft.set(RpcResultBuilder.<ScaleinComputesTepDeleteOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Failed to read the compute node " + e.getMessage()).build());
return ft;
}
if (tz.isPresent() && tz.get().getTransportZone() != null) {
for (TransportZone zone : tz.get().getTransportZone()) {
if (zone.getVteps() == null) {
continue;
}
for (Vteps vteps : zone.getVteps().values()) {
if (vteps.getDpnId().equals(computeNode.getDpnid())) {
InstanceIdentifier<Vteps> dpnVtepIid = InstanceIdentifier.create(TransportZones.class).child(TransportZone.class, zone.key()).child(Vteps.class, vteps.key());
LOG.error("Cloudscaler deleting dpn {}", vteps);
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
tx.delete(dpnVtepIid);
}), LOG, "Cloudscaler Failed to delete the itm tep");
}
}
}
}
}
InstanceIdentifier.create(TransportZones.class).child(TransportZone.class).child(Vteps.class);
} catch (Throwable e) {
LOG.error("Failed to read the transport zone ", e);
ft.set(RpcResultBuilder.<ScaleinComputesTepDeleteOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Failed to read the transport zone " + e.getMessage()).build());
return ft;
}
ft.set(RpcResultBuilder.<ScaleinComputesTepDeleteOutput>success().build());
return ft;
}
Aggregations