use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeRouterFromFloatingIpInfo.
private void removeRouterFromFloatingIpInfo(Router update, DataBroker broker) {
Uuid routerId = update.getUuid();
InstanceIdentifier.InstanceIdentifierBuilder<RouterPorts> routerPortsIdentifierBuilder = InstanceIdentifier.builder(FloatingIpInfo.class).child(RouterPorts.class, new RouterPortsKey(routerId.getValue()));
try {
Optional<RouterPorts> optionalRouterPorts = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
if (optionalRouterPorts.isPresent()) {
SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
}
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Failed to read from FloatingIpInfo DS for routerid {}", routerId, e);
}
}
use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project netvirt by opendaylight.
the class NeutronvpnNatManager method addExternalSubnet.
public void addExternalSubnet(Uuid networkId, Uuid subnetId, List<Uuid> routerIds) {
InstanceIdentifier<Subnets> subnetsIdentifier = InstanceIdentifier.builder(ExternalSubnets.class).child(Subnets.class, new SubnetsKey(subnetId)).build();
try {
Subnets newExternalSubnets = createSubnets(subnetId, networkId, routerIds);
LOG.debug("Creating external subnet {}", newExternalSubnets);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetsIdentifier, newExternalSubnets);
} catch (TransactionCommitFailedException ex) {
LOG.error("Creation of External Subnets {} failed", subnetId, ex);
}
}
use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeExternalNetworkFromRouter.
public void removeExternalNetworkFromRouter(Uuid origExtNetId, Router update, List<ExternalFixedIps> origExtFixedIps) {
Uuid routerId = update.getUuid();
// Remove the router to the ExtRouters list
removeExternalRouter(update);
// Remove router entry from floating-ip-info list
removeRouterFromFloatingIpInfo(update, dataBroker);
// Remove the router from External Subnets
removeRouterFromExternalSubnets(routerId, origExtNetId, origExtFixedIps);
// Remove the router from the ExternalNetworks list
InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(origExtNetId)).build();
Optional<Networks> optionalNets = null;
try {
optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
} catch (ReadFailedException ex) {
LOG.error("removeExternalNetworkFromRouter: Failed to remove provider network {} from router {}", origExtNetId.getValue(), routerId.getValue(), ex);
return;
}
if (!optionalNets.isPresent()) {
LOG.error("removeExternalNetworkFromRouter: Provider Network {} not present in the NVPN datamodel", origExtNetId.getValue());
return;
}
Networks nets = optionalNets.get();
try {
NetworksBuilder builder = new NetworksBuilder(nets);
List<Uuid> rtrList = builder.getRouterIds();
if (rtrList != null) {
rtrList.remove(routerId);
builder.setRouterIds(rtrList);
Networks networkss = builder.build();
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
LOG.trace("removeExternalNetworkFromRouter: Remove router {} from External Networks node {}", routerId, origExtNetId.getValue());
}
} catch (TransactionCommitFailedException ex) {
LOG.error("removeExternalNetworkFromRouter: Failed to remove provider network {} from router {}", origExtNetId.getValue(), routerId.getValue(), ex);
}
// Remove the vpnInternetId fromSubnetmap
Network net = neutronvpnUtils.getNeutronNetwork(nets.getId());
List<Uuid> submapIds = neutronvpnUtils.getPrivateSubnetsToExport(net);
for (Uuid snId : submapIds) {
Subnetmap subnetMap = neutronvpnUtils.getSubnetmap(snId);
if ((subnetMap == null) || (subnetMap.getInternetVpnId() == null)) {
LOG.error("removeExternalNetworkFromRouter: Can not find Subnetmap for SubnetId {} in ConfigDS", snId.getValue());
continue;
}
LOG.trace("removeExternalNetworkFromRouter: Remove Internet VPN Id {} from SubnetMap {}", subnetMap.getInternetVpnId(), subnetMap.getId());
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetMap.getSubnetIp());
if (ipVers == IpVersionChoice.IPV6) {
nvpnManager.updateVpnInternetForSubnet(subnetMap, subnetMap.getInternetVpnId(), false);
LOG.debug("removeExternalNetworkFromRouter: Withdraw IPv6 routes from VPN {}", subnetMap.getInternetVpnId());
}
}
}
use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project netvirt by opendaylight.
the class NeutronvpnNatManager method addExternalNetwork.
public void addExternalNetwork(Network net) {
Uuid extNetId = net.getUuid();
// Create and add Networks object for this External Network to the ExternalNetworks list
InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
try {
LOG.trace(" Creating/Updating a new Networks node {}", extNetId.getValue());
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
if (optionalNets.isPresent()) {
LOG.error("External Network {} already detected to be present", extNetId.getValue());
return;
}
ProviderTypes provType = NeutronvpnUtils.getProviderNetworkType(net);
if (provType == null) {
LOG.error("Unable to get Network Provider Type for network {}", extNetId);
return;
}
NetworksBuilder builder = null;
builder = new NetworksBuilder().setKey(new NetworksKey(extNetId)).setId(extNetId);
builder.setVpnid(neutronvpnUtils.getVpnForNetwork(extNetId));
builder.setRouterIds(new ArrayList<>());
builder.setProviderNetworkType(provType);
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Creating externalnetworks {}", networkss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
LOG.trace("Wrote externalnetwork successfully to CONFIG Datastore");
} catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Creation of External Network {} failed", extNetId.getValue(), ex);
}
}
use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method writeFlow.
private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(final Void notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error(throwable.getMessage(), throwable);
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
}, MoreExecutors.directExecutor());
}
Aggregations