use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.
the class ElanInterfaceManager method createElanInterfacesList.
private DpnInterfaces createElanInterfacesList(String elanInstanceName, String interfaceName, BigInteger dpId, WriteTransaction tx) {
List<String> interfaceNames = new ArrayList<>();
interfaceNames.add(interfaceName);
DpnInterfaces dpnInterface = new DpnInterfacesBuilder().setDpId(dpId).setInterfaces(interfaceNames).setKey(new DpnInterfacesKey(dpId)).build();
tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId), dpnInterface, WriteTransaction.CREATE_MISSING_PARENTS);
return dpnInterface;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.
the class ElanInterfaceManager method updateElanDpnInterfacesList.
private DpnInterfaces updateElanDpnInterfacesList(String elanInstanceName, BigInteger dpId, List<String> interfaceNames, WriteTransaction tx) {
DpnInterfaces dpnInterface = new DpnInterfacesBuilder().setDpId(dpId).setInterfaces(interfaceNames).setKey(new DpnInterfacesKey(dpId)).build();
tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId), dpnInterface, WriteTransaction.CREATE_MISSING_PARENTS);
return dpnInterface;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.
the class VpnUtil method addRouterPortToElanDpn.
public static void addRouterPortToElanDpn(String elanInstanceName, String routerInterfacePortId, String vpnName, BigInteger dpnId, DataBroker dataBroker) {
InstanceIdentifier<DpnInterfaces> elanDpnInterfaceId = getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpnId);
Optional<DpnInterfaces> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
List<String> elanInterfaceList;
DpnInterfaces dpnInterface;
if (!dpnInElanInterfaces.isPresent()) {
elanInterfaceList = new ArrayList<>();
} else {
dpnInterface = dpnInElanInterfaces.get();
elanInterfaceList = dpnInterface.getInterfaces();
}
if (!elanInterfaceList.contains(routerInterfacePortId)) {
elanInterfaceList.add(routerInterfacePortId);
dpnInterface = new DpnInterfacesBuilder().setDpId(dpnId).setInterfaces(elanInterfaceList).setKey(new DpnInterfacesKey(dpnId)).build();
VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId, dpnInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.
the class VpnUtil method removeRouterPortFromElanDpn.
public static void removeRouterPortFromElanDpn(String elanInstanceName, String routerInterfacePortId, String vpnName, BigInteger dpnId, DataBroker dataBroker) {
InstanceIdentifier<DpnInterfaces> elanDpnInterfaceId = getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpnId);
Optional<DpnInterfaces> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
List<String> elanInterfaceList;
DpnInterfaces dpnInterface;
if (!dpnInElanInterfaces.isPresent()) {
LOG.info("No interface in any dpn for {}", vpnName);
return;
} else {
dpnInterface = dpnInElanInterfaces.get();
elanInterfaceList = dpnInterface.getInterfaces();
}
if (!elanInterfaceList.contains(routerInterfacePortId)) {
LOG.info("Router port not present in DPN {} for VPN {}", dpnId, vpnName);
return;
}
elanInterfaceList.remove(routerInterfacePortId);
dpnInterface = new DpnInterfacesBuilder().setDpId(dpnId).setInterfaces(elanInterfaceList).setKey(new DpnInterfacesKey(dpnId)).build();
VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId, dpnInterface);
}
Aggregations