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 ItmManagerRpcService method getTunnelEndPointByDpnIdFromTranPortZone.
private Map<Uint64, ComputesBuilder> getTunnelEndPointByDpnIdFromTranPortZone(Collection<Uint64> dpnIds) throws ReadFailedException {
TransportZones transportZones = singleTransactionDataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(TransportZones.class).build());
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
throw new IllegalStateException("Failed to find transport zones in config datastore");
}
Map<Uint64, ComputesBuilder> result = new HashMap<>();
for (TransportZone transportZone : transportZones.getTransportZone()) {
for (Vteps vtep : transportZone.getVteps().values()) {
if (dpnIds.contains(vtep.getDpnId())) {
result.putIfAbsent(vtep.getDpnId(), new ComputesBuilder().setZoneName(transportZone.getZoneName()).setDpnId(vtep.getDpnId()).setNodeId(getNodeId(vtep.getDpnId())).setTepIp(Collections.singletonList(vtep.getIpAddress())));
}
}
}
for (Uint64 dpnId : dpnIds) {
if (!result.containsKey(dpnId)) {
throw new IllegalStateException("Failed to find dpn id " + dpnId + " in transport zone");
}
}
return result;
}
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 configureTunnelType.
public void configureTunnelType(String transportZoneName, String tunnelType) throws ExecutionException, InterruptedException {
LOG.debug("configureTunnelType {} for transportZone {}", tunnelType, transportZoneName);
TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker);
Class<? extends TunnelTypeBase> tunType;
if (transportZoneFromConfigDS != null) {
if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.", transportZoneName, tunnelType);
return;
} else {
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
if (Objects.equals(transportZoneFromConfigDS.getTunnelType(), tunType)) {
// controller restart, then nothing to do now. Just return.
return;
}
}
}
// get tunnel-type
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
InstanceIdentifier<TransportZones> path = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> tzones = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
TransportZone tzone = new TransportZoneBuilder().withKey(new TransportZoneKey(transportZoneName)).setTunnelType(tunType).build();
List<TransportZone> tzList = new ArrayList<>();
if (tzones.isPresent()) {
final List<TransportZone> lst = tzones.get().getTransportZone();
if (lst != null) {
tzList.addAll(lst);
}
}
tzList.add(tzone);
TransportZones transportZones = new TransportZonesBuilder().setTransportZone(tzList).build();
/*InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).
child(TransportZone.class, new TransportZoneKey(transportZoneName)).build();
TransportZone transportZone = new TransportZoneBuilder().setZoneName(transportZoneName)
.setTunnelType(tunType)
.withKey(new TransportZoneKey(transportZoneName)).build();*/
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(path, transportZones)).get();
}
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) throws TepException {
if (tunnelLists == null || tunnelLists.isEmpty()) {
handleError("No Internal Tunnels Exist");
return;
}
if (!tunnelMonitorEnabled) {
System.out.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 (TepTypeInternal.class.equals(tunnelInst.getDstInfo().getTepDeviceType())) {
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 (TunnelTypeVxlan.class.equals(tunType)) {
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(), tunnelInst.getSrcInfo().getTepIp().stringValue(), tunnelInst.getDstInfo().getTepIp().stringValue(), 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 CloudscalerRpcServiceImpl method scaleinComputesEnd2.
@SuppressWarnings("checkstyle:IllegalCatch")
public ListenableFuture<RpcResult<ScaleinComputesEndOutput>> scaleinComputesEnd2(ScaleinComputesEndInput input) {
try {
for (String computeName : input.getScaleinComputeNames()) {
ComputeNode computeNode;
try {
computeNode = computeNodeManager.getComputeNodeFromName(computeName);
if (computeNode == null) {
LOG.error("Cloudscaler Failed to find the compute {} for scale in end ", computeName);
return Futures.immediateFuture(IN_PROGRESS_RPC_RESPONSE);
}
} catch (ReadFailedException e) {
LOG.error("Cloudscaler Failed to read the compute node {}", e.getMessage());
return Futures.immediateFuture(RpcResultBuilder.<ScaleinComputesEndOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Failed to read the compute node " + e.getMessage()).build());
}
LOG.info("Cloudscaler Deleting compute node details {}", computeNode);
LOG.info("Cloudscaler Deleting compute node details {}", buildOpenflowNodeIid(computeNode));
LOG.info("Cloudscaler Deleting compute node details {}", buildOvsdbNodeId(computeNode));
// FIXME: why don't we run this as one transaction?!
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
computeNodeManager.deleteComputeNode(tx, computeNode);
}), LOG, "Cloudscaler Failed to delete the compute node");
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
tx.delete(buildOpenflowNodeIid(computeNode));
}), LOG, "Cloudscaler Failed to delete the config inventory");
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
tx.delete(buildOvsdbNodeId(computeNode));
}), LOG, "Cloudscaler Failed to delete the config topology");
}
} catch (Throwable e) {
LOG.error("Cloudscaler Failed to do scale in end {} ", input, e);
return Futures.immediateFuture(RpcResultBuilder.<ScaleinComputesEndOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Failed to read the transport zone " + e.getMessage()).build());
}
return Futures.immediateFuture(DONE_RPC_RESPONSE);
}
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 netconf by opendaylight.
the class CallhomeStatusReporter method newDevice.
private static Device newDevice(final String id, final PublicKey serverKey, final Device1.DeviceStatus status) {
// used only for netconf devices that are connected via SSH transport and global credentials
String sshEncodedKey = serverKey.toString();
try {
sshEncodedKey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
} catch (IOException e) {
LOG.warn("Unable to encode public key to ssh format.", e);
}
final SshClientParams sshParams = new SshClientParamsBuilder().setHostKey(sshEncodedKey).build();
final Transport transport = new SshBuilder().setSshClientParams(sshParams).build();
return new DeviceBuilder().setUniqueId(id).withKey(new DeviceKey(id)).setTransport(transport).addAugmentation(new Device1Builder().setDeviceStatus(status).build()).build();
}
Aggregations