use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GwValidateCli method verifyL2GatewayConnections.
private void verifyL2GatewayConnections() {
boolean isValid = true;
for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
List<Devices> devices = l2gateway.getDevices();
for (Devices device : devices) {
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
if (!isValid) {
continue;
}
NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
if (isValid) {
isValid = verifyMcastMac(logicalSwitchName, nodeIid);
verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
if (elanL2gatewayDevice == null) {
pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GwValidateCli method readNodes.
private void readNodes() throws ReadFailedException {
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
InstanceIdentifier<Topology> topoId = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
Optional<Topology> operationalTopoOptional = tx.read(LogicalDatastoreType.OPERATIONAL, topoId).checkedGet();
Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
if (operationalTopoOptional.isPresent()) {
for (Node node : operationalTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
operationalNodes.put(nodeIid, node);
}
}
if (configTopoOptional.isPresent()) {
for (Node node : configTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
configNodes.put(nodeIid, node);
}
}
fillNodesData(operationalNodes, operationalNodesData);
fillNodesData(configNodes, configNodesData);
Optional<ElanInstances> elanInstancesOptional = tx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build()).checkedGet();
if (elanInstancesOptional.isPresent() && elanInstancesOptional.get().getElanInstance() != null) {
for (ElanInstance elanInstance : elanInstancesOptional.get().getElanInstance()) {
elanInstanceMap.put(elanInstance.getElanInstanceName(), elanInstance);
}
}
l2gatewayConnections = L2GatewayConnectionUtils.getAllL2gatewayConnections(dataBroker);
l2gateways = L2GatewayConnectionUtils.getL2gatewayList(dataBroker);
for (L2gateway l2gateway : l2gateways) {
uuidToL2Gateway.put(l2gateway.getUuid(), l2gateway);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method handlePortAdded.
private List<ListenableFuture<Void>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
Node psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
if (psNode != null) {
String psName = psNode.getAugmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (isL2GatewayConfigured(l2GwDevice)) {
List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
String newPortId = portAdded.getTpId().getValue();
NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
}
} else {
LOG.error("{} details are not present in L2Gateway Cache", psName);
}
} else {
LOG.error("{} entry not in config datastore", psNodeId);
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method getVlanBindings.
private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName, String newPortId) {
List<VlanBindings> vlanBindings = new ArrayList<>();
for (L2gatewayConnection l2GwConn : l2GwConns) {
L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GwConn.getL2gatewayId());
if (l2Gateway == null) {
LOG.error("L2Gateway with id {} is not present", l2GwConn.getL2gatewayId().getValue());
} else {
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(l2GwConn.getNetworkId().getValue());
List<Devices> l2Devices = l2Gateway.getDevices();
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
if (l2DeviceName != null && l2DeviceName.equals(psName)) {
for (Interfaces deviceInterface : l2Device.getInterfaces()) {
if (deviceInterface.getInterfaceName().equals(newPortId)) {
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
Integer segmentationId = l2GwConn.getSegmentId();
int defaultVlanId = segmentationId != null ? segmentationId : 0;
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, defaultVlanId, logicalSwitchName));
}
}
}
}
}
}
}
return vlanBindings;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method associateHwvtepsToElan.
private void associateHwvtepsToElan(ElanInstance elanInstance, L2gateway l2Gateway, L2gatewayConnection input, String l2GwDeviceName) {
String elanName = elanInstance.getElanInstanceName();
Integer defaultVlan = input.getSegmentId();
Uuid l2GwConnId = input.getKey().getUuid();
List<Devices> l2Devices = l2Gateway.getDevices();
LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId, l2Devices);
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
// preprovisioning/re-provisioning
if (l2GwDeviceName != null && !l2GwDeviceName.equals(l2DeviceName)) {
LOG.debug("Associating Hwvtep to ELAN is not been processed for {}; as only {} got connected now!", l2DeviceName, l2GwDeviceName);
continue;
}
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
if (isL2GwDeviceConnected(l2GatewayDevice)) {
NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
// Delete pending delete logical switch task if scheduled
elanL2GatewayUtils.cancelDeleteLogicalSwitch(hwvtepNodeId, ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName));
// Add L2 Gateway device to 'ElanL2GwDevice' cache
boolean createLogicalSwitch;
LogicalSwitches logicalSwitch = HwvtepUtils.getLogicalSwitch(broker, LogicalDatastoreType.CONFIGURATION, hwvtepNodeId, elanName);
if (logicalSwitch == null) {
HwvtepLogicalSwitchListener hwVTEPLogicalSwitchListener = new HwvtepLogicalSwitchListener(elanInstanceCache, elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils, this, l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
hwVTEPLogicalSwitchListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
closeables.add(hwVTEPLogicalSwitchListener);
createLogicalSwitch = true;
} else {
addL2DeviceToElanL2GwCache(elanName, l2GatewayDevice, l2GwConnId, l2Device);
createLogicalSwitch = false;
}
AssociateHwvtepToElanJob associateHwvtepToElanJob = new AssociateHwvtepToElanJob(broker, elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanInstanceCache, l2GatewayDevice, elanInstance, l2Device, defaultVlan, createLogicalSwitch);
elanClusterUtils.runOnlyInOwnerNode(associateHwvtepToElanJob.getJobKey(), "create logical switch in hwvtep topo", associateHwvtepToElanJob);
} else {
LOG.info("L2GwConn create is not handled for device with id {} as it's not connected", l2DeviceName);
}
}
}
Aggregations