use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.coe.Pods in project netvirt by opendaylight.
the class PodListener method onPodInterfacesChanged.
public void onPodInterfacesChanged(final DataObjectModification<Interface> dataObjectModification, final InstanceIdentifier<Pods> rootIdentifier, DataObjectModification<Pods> rootNode) {
Pods pods = rootNode.getDataAfter();
Pods podsBefore = rootNode.getDataBefore();
Interface podInterfaceBefore = dataObjectModification.getDataBefore();
Interface podInterfaceAfter = dataObjectModification.getDataAfter();
switch(dataObjectModification.getModificationType()) {
case DELETE:
remove(podsBefore, podInterfaceBefore);
break;
case SUBTREE_MODIFIED:
update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
break;
case WRITE:
if (podInterfaceBefore == null) {
add(rootIdentifier, pods, podInterfaceAfter);
} else {
update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
}
break;
default:
LOG.error("Unhandled Modificiation Type{} for {}", dataObjectModification.getModificationType(), rootIdentifier);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.coe.Pods in project netvirt by opendaylight.
the class CoeUtils method createPortIpAdjacencies.
static Adjacencies createPortIpAdjacencies(Pods pod, String interfaceName, String macAddress, Boolean isRouterInterface) {
List<Adjacency> adjList = new ArrayList<>();
LOG.trace("create config adjacencies for Port: {}", interfaceName);
IpAddress ip = pod.getInterface().get(0).getIpAddress();
String ipValue = ip.getIpv4Address() != null ? ip.getIpv4Address().getValue() : ip.getIpv6Address().getValue();
String ipPrefix = ip.getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
String hostIp = new String(pod.getHostIpAddress().getValue());
UUID subnetId = UUID.nameUUIDFromBytes(hostIp.getBytes(StandardCharsets.UTF_8));
String gatewayIP = ipValue.replaceFirst("\\d+$", "1");
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(macAddress).setAdjacencyType(Adjacency.AdjacencyType.PrimaryAdjacency).setSubnetId(new Uuid(subnetId.toString())).setSubnetGatewayIp(gatewayIP).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
// }
return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.coe.Pods in project netvirt by opendaylight.
the class CoeUtils method createVpnInterface.
public static void createVpnInterface(String vpnName, Pods pod, String interfaceName, String macAddress, boolean isRouterInterface, WriteTransaction wrtConfigTxn) {
LOG.trace("createVpnInterface for Port: {}, isRouterInterface: {}", interfaceName, isRouterInterface);
List<VpnInstanceNames> listVpn = new ArrayList<>();
listVpn.add(new VpnInstanceNamesBuilder().setKey(new VpnInstanceNamesKey(vpnName)).setVpnName(vpnName).setAssociatedSubnetType(VpnInstanceNames.AssociatedSubnetType.V4Subnet).build());
VpnInterfaceBuilder vpnb = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(interfaceName)).setName(interfaceName).setVpnInstanceNames(listVpn).setRouterInterface(isRouterInterface);
Adjacencies adjs = createPortIpAdjacencies(pod, interfaceName, macAddress, isRouterInterface);
if (adjs != null) {
vpnb.addAugmentation(Adjacencies.class, adjs);
}
VpnInterface vpnIf = vpnb.build();
LOG.info("Creating vpn interface {}", vpnIf);
InstanceIdentifier<VpnInterface> vpnIfIdentifier = buildVpnInterfaceIdentifier(interfaceName);
wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.coe.Pods in project netvirt by opendaylight.
the class CoeUtils method createPodNameToPodUuidMap.
public static void createPodNameToPodUuidMap(String podName, InstanceIdentifier<Pods> pod, WriteTransaction writeTransaction) {
InstanceIdentifier<PodIdentifier> id = InstanceIdentifier.builder(PodidentifierInfo.class).child(PodIdentifier.class, new PodIdentifierKey(podName)).build();
PodIdentifier podIdentifier = new PodIdentifierBuilder().setKey(new PodIdentifierKey(podName)).setPodName(podName).setPodUuid(pod).build();
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, id, podIdentifier);
LOG.debug("Creating podnametouuid map {} to {}", podName, pod);
}
Aggregations