use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method addEbgpMultihop.
public void addEbgpMultihop(String nbrIp, int hops) {
Ipv4Address nbrAddr = new Ipv4Address(nbrIp);
InstanceIdentifier.InstanceIdentifierBuilder<EbgpMultihop> iib = InstanceIdentifier.builder(Bgp.class).child(NeighborsContainer.class).child(Neighbors.class, new NeighborsKey(nbrAddr)).child(EbgpMultihop.class);
InstanceIdentifier<EbgpMultihop> iid = iib.build();
EbgpMultihop dto = new EbgpMultihopBuilder().setPeerIp(nbrAddr).setNhops((long) hops).build();
update(iid, dto);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class ElanInstanceManager method update.
@Override
public void update(InstanceIdentifier<ElanInstance> identifier, ElanInstance original, ElanInstance update) {
EVENT_LOGGER.debug("ELAN-Instance, UPDATE {}", original.getElanInstanceName());
Uint32 existingElanTag = original.getElanTag();
String elanName = update.getElanInstanceName();
if (existingElanTag == null || !existingElanTag.equals(update.getElanTag())) {
if (update.getElanTag() == null || update.getElanTag().longValue() == 0L) {
// update the elan-Instance with new properties
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> ElanUtils.updateOperationalDataStore(idManager, update, new ArrayList<>(), confTx, operTx)), LOG, "Error updating ELAN tag in ELAN instance for config " + "transaction")), LOG, "Error updating ELAN tag in ELAN instance for operational transaction");
} else {
jobCoordinator.enqueueJob(elanName, () -> elanInterfaceManager.handleunprocessedElanInterfaces(update), ElanConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class ElanInterfaceManager method update.
/*
* Possible Scenarios for update
* a. if orig={1,2,3,4} and updated=null or updated={}
then all {1,2,3,4} should be removed
b. if orig=null or orig={} and updated ={1,2,3,4}
then all {1,2,3,4} should be added
c. if orig = {1,2,3,4} updated={2,3,4}
then 1 should be removed
d. basically if orig = { 1,2,3,4} and updated is {1,2,3,4,5}
then we should just add 5
e. if orig = {1,2,3,4} updated={2,3,4,5}
then 1 should be removed , 5 should be added
* */
@SuppressWarnings("checkstyle:ForbidCertainMethod")
@Override
public void update(InstanceIdentifier<ElanInterface> identifier, ElanInterface original, ElanInterface update) {
// updating the static-Mac Entries for the existing elanInterface
String elanName = update.getElanInstanceName();
String interfaceName = update.getName();
LOG.info("Update static mac entries for elan interface {} in elan instance {}", interfaceName, elanName);
EVENT_LOGGER.debug("ELAN-Interface, UPDATE {} Instance {}", original.getName(), elanName);
List<StaticMacEntries> originalStaticMacEntries = new ArrayList<StaticMacEntries>(original.nonnullStaticMacEntries().values());
List<StaticMacEntries> updatedStaticMacEntries = new ArrayList<StaticMacEntries>(update.nonnullStaticMacEntries().values());
List<StaticMacEntries> deletedEntries = ElanUtils.diffOf(originalStaticMacEntries, updatedStaticMacEntries);
List<StaticMacEntries> updatedEntries = ElanUtils.diffOf(updatedStaticMacEntries, originalStaticMacEntries);
deletedEntries.forEach((deletedEntry) -> removeInterfaceStaticMacEntries(elanName, interfaceName, deletedEntry.getMacAddress()));
/*if updatedStaticMacEntries is NOT NULL, which means as part of update call these entries were added.
* Hence add the macentries for the same.*/
for (StaticMacEntries staticMacEntry : updatedEntries) {
InstanceIdentifier<MacEntry> macEntryIdentifier = getMacEntryOperationalDataPath(elanName, staticMacEntry.getMacAddress());
addErrorLogging(ElanUtils.waitForTransactionToComplete(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
Optional<MacEntry> existingMacEntry = tx.read(macEntryIdentifier).get();
if (existingMacEntry.isPresent()) {
LOG.debug("updating elan interface forwarding table for mac entry {} elan instance {}", existingMacEntry.get(), elanName);
elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
} else {
LOG.info("Adding elan interface forwarding table for mac entry {} elan interface" + " {} elan instance {}.", staticMacEntry.getMacAddress(), interfaceName, elanName);
elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanName, interfaceName, staticMacEntry, tx);
}
})), LOG, "Error in update: identifier={}, original={}, update={}", identifier, original, update);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class ElanServiceProvider method handleExternalElanNetwork.
private void handleExternalElanNetwork(ElanInstance elanInstance, boolean update, BiFunction<ElanInstance, String, Void> function) {
String elanInstanceName = elanInstance.getElanInstanceName();
boolean isFlatOrVlanNetwork = (ElanUtils.isFlat(elanInstance) || ElanUtils.isVlan(elanInstance));
if (!isFlatOrVlanNetwork) {
LOG.error("Network is not of type FLAT/VLAN." + "Ignoring Elan-interface creation for given ProviderInterface {}", elanInstance.getPhysicalNetworkName());
return;
}
if (elanInstance.getPhysicalNetworkName() == null) {
LOG.trace("No physical network attached to {}", elanInstanceName);
return;
}
Map<NodeKey, Node> nodes = southboundUtils.getOvsdbNodes();
if (nodes == null || nodes.isEmpty()) {
LOG.trace("No OVS nodes found while creating external network for ELAN {}", elanInstance.getElanInstanceName());
return;
}
for (Node node : nodes.values()) {
if (bridgeMgr.isIntegrationBridge(node)) {
if (update && !elanInstance.isExternal()) {
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanInstanceName, bridgeMgr.getDatapathId(node));
if (dpnInterfaces == null || dpnInterfaces.getInterfaces().isEmpty()) {
continue;
}
}
String interfaceName = bridgeMgr.getProviderInterfaceName(node, elanInstance.getPhysicalNetworkName());
function.apply(elanInstance, interfaceName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update in project netvirt by opendaylight.
the class NeutronvpnUtils method updateVpnInstanceWithBgpVpnType.
public void updateVpnInstanceWithBgpVpnType(VpnInstance.BgpvpnType bgpvpnType, @NonNull Uuid vpnName) {
jobCoordinator.enqueueJob("VPN-" + vpnName.getValue(), () -> {
VpnInstance vpnInstance = getVpnInstance(vpnName);
if (vpnInstance == null) {
LOG.error("updateVpnInstanceWithBgpVpnType: Failed to Update VpnInstance {} with BGP-VPN type {}." + "VpnInstance is does not exist in the CONFIG. Do nothing.", vpnName.getValue(), bgpvpnType);
return Collections.emptyList();
}
if (vpnInstance.isL2vpn()) {
LOG.error("updateVpnInstanceWithBgpVpnType: Failed to Update VpnInstance {} with BGP-VPN type {}." + "VpnInstance is L2 instance. Do nothing.", vpnName.getValue(), bgpvpnType);
return Collections.emptyList();
}
VpnInstanceBuilder builder = new VpnInstanceBuilder(vpnInstance);
builder.setBgpvpnType(bgpvpnType);
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class, new VpnInstanceKey(vpnName.getValue())).build();
LOG.info("updateVpnInstanceWithBgpVpnType: Successfully updated the VpnInstance {} with BGP-VPN type {}", vpnName.getValue(), bgpvpnType);
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.merge(vpnIdentifier, builder.build())));
});
}
Aggregations