use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class VpnToDpnListener method programVpnScfFlowsOnDpn.
private void programVpnScfFlowsOnDpn(BigInteger dpnId, String vpnName, String rd, int addOrRemove) {
String addedOrRemovedTxt = addOrRemove == NwConstants.ADD_FLOW ? " added " : " removed";
LOG.debug("DpnToVpn {} event received: dpn={} vpn={} rd={}", addedOrRemovedTxt, dpnId, vpnName, rd);
if (dpnId == null) {
LOG.warn("Dpn to Vpn {} event received, but no DPN specified in event", addedOrRemovedTxt);
return;
}
if (vpnName == null) {
LOG.warn("Dpn to Vpn {} event received, but no VPN specified in event", addedOrRemovedTxt);
return;
}
if (rd == null) {
LOG.warn("Dpn to Vpn {} event received, but no RD specified in event", addedOrRemovedTxt);
return;
}
try {
Optional<VpnToPseudoPortData> optVpnToPseudoPortInfo = VpnServiceChainUtils.getVpnPseudoPortData(broker, rd);
if (!optVpnToPseudoPortInfo.isPresent()) {
LOG.debug("Dpn to Vpn {} event received: Could not find VpnPseudoLportTag for VPN name={} rd={}", addedOrRemovedTxt, vpnName, rd);
return;
}
VpnToPseudoPortData vpnToPseudoPortInfo = optVpnToPseudoPortInfo.get();
// Vpn2Scf flows (LFIB + LportDispatcher)
// TODO: Should we filter out by bgp origin
List<VrfEntry> allVpnVrfEntries = VpnServiceChainUtils.getAllVrfEntries(broker, rd);
vpnScHandler.programVpnToScfPipelineOnDpn(dpnId, allVpnVrfEntries, vpnToPseudoPortInfo.getScfTableId(), vpnToPseudoPortInfo.getScfTag(), vpnToPseudoPortInfo.getVpnLportTag().intValue(), addOrRemove);
// Scf2Vpn flow (LportDispatcher)
long vpnId = addOrRemove == NwConstants.ADD_FLOW ? VpnServiceChainUtils.getVpnId(broker, vpnName) : CloudServiceChainConstants.INVALID_VPN_TAG;
VpnServiceChainUtils.programLPortDispatcherFlowForScfToVpn(mdsalMgr, vpnId, dpnId, vpnToPseudoPortInfo.getVpnLportTag().intValue(), addOrRemove);
} catch (ReadFailedException e) {
LOG.error("Error retrieving the VPN to pseudo-port data for {}", rd, e);
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class WeightedCentralizedSwitchScheduler method addToDpnMaps.
private void addToDpnMaps(String routerName, List<Uuid> addedSubnetIds, BigInteger primarySwitchId) {
if (addedSubnetIds == null || addedSubnetIds.isEmpty()) {
LOG.debug("addToDpnMaps no subnets associated with {}", routerName);
return;
}
String primaryRd = NatUtil.getPrimaryRd(dataBroker, routerName);
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
for (Uuid subnetUuid : addedSubnetIds) {
try {
Subnetmap subnetMapEntry = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.CONFIGURATION, getSubnetMapIdentifier(subnetUuid));
Uuid routerPortUuid = subnetMapEntry.getRouterInterfacePortId();
subnetIdToRouterPortMap.put(subnetUuid.getValue(), routerPortUuid.getValue());
vpnFootprintService.updateVpnToDpnMapping(primarySwitchId, routerName, primaryRd, routerPortUuid.getValue(), null, true);
NatUtil.addToNeutronRouterDpnsMap(dataBroker, routerName, routerPortUuid.getValue(), primarySwitchId, writeOperTxn);
NatUtil.addToDpnRoutersMap(dataBroker, routerName, routerPortUuid.getValue(), primarySwitchId, writeOperTxn);
} catch (ReadFailedException e) {
LOG.error("addToDpnMaps failed for {}", routerName);
}
}
writeOperTxn.submit();
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class UpgradeStateListener method update.
@Override
public void update(@Nonnull Config original, Config updated) {
if (natMode != NatserviceConfig.NatMode.Conntrack) {
return;
}
LOG.info("UpgradeStateListener update from {} to {}", original, updated);
if (!(original.isUpgradeInProgress() && !updated.isUpgradeInProgress())) {
return;
}
SingleTransactionDataBroker reader = new SingleTransactionDataBroker(dataBroker);
ExtRouters routers;
try {
routers = reader.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(ExtRouters.class));
} catch (ReadFailedException e) {
LOG.error("Error reading external routers", e);
return;
}
for (Routers router : routers.getRouters()) {
List<ExternalIps> externalIps = router.getExternalIps();
if (router.isEnableSnat() && externalIps != null && !externalIps.isEmpty()) {
centralizedSwitchScheduler.scheduleCentralizedSwitch(router);
}
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class ShowFibCommand method doExecute.
@Override
protected Object doExecute() {
PrintStream console = session.getConsole();
if (prefixOrSubnetOption != null && prefixOrSubnetOption.length() > 0) {
prefixOrSubnet = prefixOrSubnetOption.replace("[", "");
prefixOrSubnet = prefixOrSubnet.replace("]", "");
if (prefixOrSubnet.indexOf("/") < 0) {
String maskFull = null;
try {
Inet4Address tempAdd = (Inet4Address) InetAddress.getByName(prefixOrSubnet);
maskFull = "/32";
} catch (SecurityException | UnknownHostException | ClassCastException e) {
maskFull = null;
}
if (maskFull == null) {
try {
Inet6Address tempAdd = (Inet6Address) InetAddress.getByName(prefixOrSubnet);
maskFull = "/128";
} catch (SecurityException | UnknownHostException | ClassCastException e) {
maskFull = null;
}
}
if (maskFull == null) {
console.println("a part of cli " + SUBNET + " is wrong => " + prefixOrSubnet);
return usage(console);
}
prefixOrSubnet += maskFull;
}
}
console.println(HEADER);
if (options == null && prefixOrSubnet == null && (addrFamList == null || addrFamList.isEmpty())) {
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
try {
FibEntries fibEntries = singleTxDb.syncRead(LogicalDatastoreType.CONFIGURATION, id);
List<VrfTables> vrfTablesList = fibEntries.getVrfTables();
if (vrfTablesList == null || vrfTablesList.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : vrfTablesList) {
printVrfTable(vrfTable, console);
}
} catch (ExpectedDataObjectNotFoundException e404) {
String errMsg = "FATAL: fib-entries container is missing from MD-SAL";
console.println("\n" + errMsg);
LOG.error(errMsg, e404);
} catch (ReadFailedException rfe) {
String errMsg = "Internal Error occurred while processing vpnservice:fib-show command";
console.println("\n" + errMsg);
LOG.error(errMsg, rfe);
}
return null;
} else {
String optionsLowerCase = options != null ? options.toLowerCase(Locale.getDefault()) : "";
switch(optionsLowerCase) {
case "fullhelp":
return usage(console);
default:
}
if ((addrFamList == null || addrFamList.isEmpty()) && (prefixOrSubnet == null || prefixOrSubnet.indexOf("/") < 5)) {
console.println("any address family is requiered or " + SUBNET + " is wrong");
usage(console);
} else {
boolean isIpv4 = false;
boolean isIpv6 = false;
boolean isL2vpn = false;
if (addrFamList != null && addrFamList.size() > 0) {
for (String addF : addrFamList) {
switch(addF.toLowerCase(Locale.getDefault())) {
case "ipv4":
isIpv4 = true;
break;
case "ipv6":
isIpv6 = true;
break;
case "l2vpn":
isL2vpn = true;
break;
default:
}
}
}
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
try {
FibEntries fibEntries = singleTxDb.syncRead(LogicalDatastoreType.CONFIGURATION, id);
List<VrfTables> vrfTablesList = fibEntries.getVrfTables();
if (vrfTablesList == null || vrfTablesList.isEmpty()) {
console.println(" No Fib entries found");
return null;
}
for (VrfTables vrfTable : vrfTablesList) {
printVrfTable(vrfTable, console, isIpv4, isIpv6, isL2vpn, prefixOrSubnet);
}
} catch (ExpectedDataObjectNotFoundException e404) {
String errMsg = "FATAL: fib-entries container is missing from MD-SAL";
console.println("\n" + errMsg);
LOG.error(errMsg, e404);
} catch (ReadFailedException rfe) {
String errMsg = "Internal Error occurred while processing vpnservice:fib-show command";
console.println("\n" + errMsg);
LOG.error(errMsg, rfe);
}
return null;
}
}
return null;
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method deleteSubnetToNetworkMapping.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void deleteSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
try {
InstanceIdentifier<NetworkMap> networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
Optional<NetworkMap> optionalNetworkMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
if (optionalNetworkMap.isPresent()) {
NetworkMapBuilder nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
if (subnetIdList.remove(subnetId)) {
if (subnetIdList.isEmpty()) {
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
LOG.debug("Deleted network node in NetworkMaps DS for subnet {} network {}", subnetId.getValue(), networkId.getValue());
} else {
nwMapBuilder.setSubnetIdList(subnetIdList);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier, nwMapBuilder.build());
LOG.debug("Deleted subnet-network mapping for subnet {} network {}", subnetId.getValue(), networkId.getValue());
}
} else {
LOG.error("Subnet {} is not mapped to network {}", subnetId.getValue(), networkId.getValue());
}
} else {
LOG.error("network {} not present for subnet {} ", networkId, subnetId);
}
} catch (ReadFailedException | RuntimeException e) {
LOG.error("Delete subnet-network mapping failed for subnet {} network {}", subnetId.getValue(), networkId.getValue());
}
}
Aggregations