use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesKey in project netvirt by opendaylight.
the class NeutronvpnManager method removeFromNeutronRouterInterfacesMap.
protected void removeFromNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
synchronized (routerId.getValue().intern()) {
InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
try {
Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
RouterInterfaces routerInterfaces = optRouterInterfaces.get();
List<Interfaces> interfaces = routerInterfaces.getInterfaces();
if (interfaces != null && interfaces.remove(routerInterface)) {
if (interfaces.isEmpty()) {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
} else {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)));
}
}
}
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Error reading the router interfaces for {}", routerInterfacesId, e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesKey in project netvirt by opendaylight.
the class NeutronvpnManager method addToNeutronRouterInterfacesMap.
protected void addToNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
synchronized (routerId.getValue().intern()) {
InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
try {
Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
} else {
// TODO Shouldn't we be doing something with builder and interfaces?
// RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
// List<Interfaces> interfaces = new ArrayList<>();
// interfaces.add(routerInterface);
SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
}
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Error reading router interfaces for {}", routerInterfacesId, e);
}
}
}
Aggregations