use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project openflowplugin by opendaylight.
the class PacketOutConvertorTest method createNodeRef.
private static NodeRef createNodeRef(final String nodeId) {
NodeKey key = new NodeKey(new NodeId(nodeId));
InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class).<Node, NodeKey>child(Node.class, key).build();
return new NodeRef(path);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project lispflowmapping by opendaylight.
the class MappingSystem method getMappingNbSbIntersection.
private MappingData getMappingNbSbIntersection(Eid src, Eid dst) {
// lookupPolicy == NB_AND_SB, we return intersection
// of NB and SB mappings, or NB mapping if intersection is empty.
MappingData nbMappingData = (MappingData) pmc.getMapping(src, dst);
if (nbMappingData == null) {
return nbMappingData;
}
// no intersection for Service Path mappings
if (dst.getAddress() instanceof ServicePath) {
return updateServicePathMappingRecord(nbMappingData, dst);
}
MappingData sbMappingData = getSbMappingWithExpiration(src, dst, null);
if (sbMappingData == null) {
return nbMappingData;
}
// both NB and SB mappings exist. Compute intersection of the mappings
return MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.
the class ItmManagerRpcService method addL2GwMlagDevice.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Future<RpcResult<java.lang.Void>> addL2GwMlagDevice(AddL2GwMlagDeviceInput input) {
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
try {
final IpAddress hwIp = input.getIpAddress();
final List<String> nodeId = input.getNodeId();
InstanceIdentifier<TransportZones> containerPath = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, containerPath, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
LOG.error("No teps configured");
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No teps Configured").build());
return result;
}
String transportZone = transportZones.getTransportZone().get(0).getZoneName();
if (transportZones.getTransportZone().get(0).getSubnets() == null || transportZones.getTransportZone().get(0).getSubnets().isEmpty()) {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No subnets Configured").build());
return result;
}
SubnetsKey subnetsKey = transportZones.getTransportZone().get(0).getSubnets().get(0).getKey();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId.get(0));
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey).build();
DeviceVteps deviceVtep = new DeviceVtepsBuilder().setKey(deviceVtepKey).setIpAddress(hwIp).setNodeId(nodeId.get(0)).setTopologyId(input.getTopologyId()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
// TO DO: add retry if it fails
LOG.trace("writing hWvtep{}", deviceVtep);
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, path, deviceVtep, true);
if (nodeId.size() == 2) {
LOG.trace("second node-id {}", nodeId.get(1));
DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp, nodeId.get(1));
InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey2).build();
DeviceVteps deviceVtep2 = new DeviceVtepsBuilder().setKey(deviceVtepKey2).setIpAddress(hwIp).setNodeId(nodeId.get(1)).setTopologyId(input.getTopologyId()).build();
// TO DO: add retry if it fails
LOG.trace("writing {}", deviceVtep2);
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, path2, deviceVtep2, true);
}
ListenableFuture<Void> futureCheck = writeTransaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = String.format("Unable to write HwVtep %s to datastore", nodeId);
LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId, hwIp);
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
}, MoreExecutors.directExecutor());
}
return result;
} catch (RuntimeException e) {
RpcResultBuilder<java.lang.Void> resultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "Adding l2 Gateway to DS Failed", e);
return Futures.immediateFuture(resultBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.
the class ItmManagerRpcService method getNodeId.
private String getNodeId(BigInteger dpnId) throws ReadFailedException {
InstanceIdentifier<BridgeRefEntry> path = InstanceIdentifier.builder(BridgeRefInfo.class).child(BridgeRefEntry.class, new BridgeRefEntryKey(dpnId)).build();
BridgeRefEntry bridgeRefEntry = singleTransactionDataBroker.syncRead(LogicalDatastoreType.OPERATIONAL, path);
return bridgeRefEntry.getBridgeReference().getValue().firstKeyOf(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class).getNodeId().getValue();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.
the class ItmManagerRpcService method addL2GwDevice.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public Future<RpcResult<java.lang.Void>> addL2GwDevice(AddL2GwDeviceInput input) {
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
boolean foundVxlanTzone = false;
try {
final IpAddress hwIp = input.getIpAddress();
final String nodeId = input.getNodeId();
// iterate through all transport zones and put TORs under vxlan
// if no vxlan tzone is cnfigured, return an error.
InstanceIdentifier<TransportZones> containerPath = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, containerPath, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
LOG.error("No transportZone configured");
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No transportZone Configured").build());
return result;
}
for (TransportZone tzone : transportZones.getTransportZone()) {
if (!tzone.getTunnelType().equals(TunnelTypeVxlan.class)) {
continue;
}
String transportZone = tzone.getZoneName();
if (tzone.getSubnets() == null || tzone.getSubnets().isEmpty()) {
continue;
}
foundVxlanTzone = true;
SubnetsKey subnetsKey = tzone.getSubnets().get(0).getKey();
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId);
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Subnets.class, subnetsKey).child(DeviceVteps.class, deviceVtepKey).build();
DeviceVteps deviceVtep = new DeviceVtepsBuilder().setKey(deviceVtepKey).setIpAddress(hwIp).setNodeId(nodeId).setTopologyId(input.getTopologyId()).build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
// TO DO: add retry if it fails
transaction.put(LogicalDatastoreType.CONFIGURATION, path, deviceVtep, true);
ListenableFuture<Void> futureCheck = transaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = String.format("Unable to write HwVtep %s to datastore", nodeId);
LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId, hwIp);
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
}
} else {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No TransportZones configured").build());
return result;
}
if (!foundVxlanTzone) {
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "No VxLan TransportZones configured").build());
}
return result;
} catch (Exception e) {
RpcResultBuilder<java.lang.Void> resultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "Adding l2 Gateway to DS Failed", e);
return Futures.immediateFuture(resultBuilder.build());
}
}
Aggregations