use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.InterfacesBuilder in project netvirt by opendaylight.
the class L2gwBuilders method buildL2gw.
public L2gateway buildL2gw(String l2gwName, String deviceName, List<String> intfNames) {
final L2gatewayBuilder l2gatewayBuilder = new L2gatewayBuilder();
String uuid = UUID.nameUUIDFromBytes(l2gwName.getBytes()).toString();
// String tenantUuid = UUID.fromString(ELAN1).toString();
l2gatewayBuilder.setUuid(new Uuid(uuid));
l2gatewayBuilder.setTenantId(new Uuid(ExpectedObjects.ELAN1));
final List<Devices> devices = new ArrayList<>();
final DevicesBuilder deviceBuilder = new DevicesBuilder();
final List<Interfaces> interfaces = new ArrayList<>();
for (String intfName : intfNames) {
final InterfacesBuilder interfacesBuilder = new InterfacesBuilder();
interfacesBuilder.setInterfaceName(intfName);
interfacesBuilder.setSegmentationIds(new ArrayList<>());
interfaces.add(interfacesBuilder.build());
}
deviceBuilder.setDeviceName(deviceName);
deviceBuilder.setUuid(new Uuid(uuid));
deviceBuilder.setInterfaces(interfaces);
devices.add(deviceBuilder.build());
l2gatewayBuilder.setDevices(devices);
return l2gatewayBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.InterfacesBuilder in project netvirt by opendaylight.
the class NeutronvpnManager method addToNeutronRouterInterfacesMap.
protected void addToNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
final InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
final ReentrantLock lock = lockForUuid(routerId);
lock.lock();
try {
Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
Interfaces routerInterface = new InterfacesBuilder().withKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
} else {
RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
List<Interfaces> interfaces = new ArrayList<>();
interfaces.add(routerInterface);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId, builder.setInterfaces(interfaces).build());
}
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
LOG.error("Error reading router interfaces for {}", routerInterfacesId, e);
} finally {
lock.unlock();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.InterfacesBuilder in project netvirt by opendaylight.
the class NeutronvpnManager method removeFromNeutronRouterInterfacesMap.
protected void removeFromNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
final InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
final ReentrantLock lock = lockForUuid(routerId);
lock.lock();
try {
Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
Interfaces routerInterface = new InterfacesBuilder().withKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
RouterInterfaces routerInterfaces = optRouterInterfaces.get();
List<Interfaces> interfaces = new ArrayList<>(routerInterfaces.nonnullInterfaces().values());
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 (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
LOG.error("Error reading the router interfaces for {}", routerInterfacesId, e);
} finally {
lock.unlock();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.InterfacesBuilder in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getDpnInterfaceList.
@Override
public ListenableFuture<GetDpnInterfaceListOutput> getDpnInterfaceList(GetDpnInterfaceListInput input) {
Uint64 dpnid = input.getDpid();
InstanceIdentifier<DpnToInterface> id = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, new DpnToInterfaceKey(dpnid)).build();
Optional<DpnToInterface> entry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
if (!entry.isPresent()) {
LOG.warn("Could not find Operational DpnToInterface info for DPN {}. Returning empty list", dpnid);
return buildEmptyInterfaceListResult();
}
Map<InterfaceNameEntryKey, InterfaceNameEntry> interfaceNameEntries = entry.get().getInterfaceNameEntry();
if (interfaceNameEntries == null || interfaceNameEntries.isEmpty()) {
LOG.debug("No Interface list found in Operational for DPN {}", dpnid);
return buildEmptyInterfaceListResult();
}
List<Interfaces> interfaceList = new ArrayList<>();
interfaceNameEntries.values().forEach((interfaceNameEntry) -> {
InterfacesBuilder intf = new InterfacesBuilder().setInterfaceName(interfaceNameEntry.getInterfaceName()).setInterfaceType(interfaceNameEntry.getInterfaceType());
interfaceList.add(intf.build());
});
// TODO as above, simplify the success case later, as we have the failure case below
return Futures.immediateFuture(new GetDpnInterfaceListOutputBuilder().setInterfaces(interfaceList).build());
}
Aggregations