long localPort = MdsalUtils.getOFPort(intf);
if (localPort == 0) {
- logger.info("programVlanRules: could not find ofPort");
+ logger.debug("programVlanRules: could not find ofPort for {}", intf.getName());
return;
}
String attachedMac = MdsalUtils.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC);
if (attachedMac == null) {
- logger.error("programVlanRules: No AttachedMac seen in {}", intf);
+ logger.debug("programVlanRules: No AttachedMac seen in {}", intf);
return;
}
String phyIfName =
bridgeConfigurationManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork());
- List<OvsdbTerminationPointAugmentation> intfs = MdsalUtils.getTerminationPointsOfBridge(node);
- for (OvsdbTerminationPointAugmentation ethIntf : intfs) {
- if (ethIntf.getName().equals(phyIfName)) {
- long ethOFPort = MdsalUtils.getOFPort(ethIntf);
- if (ethOFPort == 0) {
- logger.warn("programVlanRules: could not find ofPort for physical port");
- return;
- }
- logger.debug("Identified eth port {} -> OF ({}) on {}",
- ethIntf.getName(), ethOFPort, node);
- // TODO: add logic to only add rule on remote nodes
- programRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(),
- attachedMac, ethOFPort);
- programLocalIngressVlanRules(node, dpid, network.getProviderSegmentationID(),
- attachedMac, localPort, ethOFPort);
- return;
- } else {
- logger.debug("programVlanRules: intf {} does not match phyIfName: {}",
- ethIntf.getName(), phyIfName);
- }
+ long ethOFPort = MdsalUtils.getOFPort(node, phyIfName);
+ if (ethOFPort == 0) {
+ logger.warn("programVlanRules: could not find ofPort for physical port {}", phyIfName);
+ return;
}
+ logger.debug("programVlanRules: Identified eth port {} -> ofPort ({}) on {}",
+ phyIfName, ethOFPort, node);
+ // TODO: add logic to only add rule on remote nodes
+ programRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(),
+ attachedMac, ethOFPort);
+ programLocalIngressVlanRules(node, dpid, network.getProviderSegmentationID(),
+ attachedMac, localPort, ethOFPort);
}
private void removeVlanRules (NeutronNetwork network, Node node, OvsdbTerminationPointAugmentation intf,
long localPort = MdsalUtils.getOFPort(intf);
if (localPort == 0) {
- logger.info("removeVlanRules: programVlanRules: could not find ofPort");
+ logger.debug("removeVlanRules: programVlanRules: could not find ofPort for {}", intf.getName());
return;
}
String attachedMac = MdsalUtils.getInterfaceExternalIdsValue(intf, Constants.EXTERNAL_ID_VM_MAC);
if (attachedMac == null) {
- logger.error("removeVlanRules: No AttachedMac seen in {}", intf);
+ logger.debug("removeVlanRules: No AttachedMac seen in {}", intf);
return;
}
- List<OvsdbTerminationPointAugmentation> intfs = MdsalUtils.getTerminationPointsOfBridge(node);
- for (OvsdbTerminationPointAugmentation ethIntf : intfs) {
- if (ethIntf.getName().equalsIgnoreCase(bridgeConfigurationManager.getPhysicalInterfaceName(
- node, network.getProviderPhysicalNetwork()))) {
- long ethOFPort = MdsalUtils.getOFPort(ethIntf);
- if (ethOFPort == 0) {
- logger.info("removeVlanRules: programVlanRules: could not find ofPort");
- return;
- }
- logger.debug("removeVlanRules: Identified eth port {} -> OF ({}) on {}",
- ethIntf.getName(), ethOFPort, node);
- removeRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(),
- attachedMac, localPort, ethOFPort);
- if (isLastInstanceOnNode) {
- removePerVlanRules(node, dpid, network.getProviderSegmentationID(), localPort, ethOFPort);
- }
- return;
- }
+ String phyIfName =
+ bridgeConfigurationManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork());
+ long ethOFPort = MdsalUtils.getOFPort(node, phyIfName);
+ if (ethOFPort == 0) {
+ logger.warn("removeVlanRules: could not find ofPort for physical port {}", phyIfName);
+ return;
+ }
+ logger.debug("removeVlanRules: Identified eth port {} -> ofPort ({}) on {}",
+ phyIfName, ethOFPort, node);
+
+ removeRemoteEgressVlanRules(node, dpid, network.getProviderSegmentationID(),
+ attachedMac, localPort, ethOFPort);
+ if (isLastInstanceOnNode) {
+ removePerVlanRules(node, dpid, network.getProviderSegmentationID(), localPort, ethOFPort);
}
}
-/*
- private removeNode(List<Node> nodes, Node node) {
- OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode);
- if(bridgeAugmentation != null){
- InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
- }
-*/
+
@Override
public boolean handleInterfaceUpdate(NeutronNetwork network, Node srcNode,
OvsdbTerminationPointAugmentation intf) {
public static List<OvsdbTerminationPointAugmentation> getTerminationPointsOfBridge(Node node) {
List<OvsdbTerminationPointAugmentation> tpAugmentations = extractTerminationPointAugmentations(node);
if(tpAugmentations.isEmpty()){
- tpAugmentations = readTerminationPointAugmentationFromDataStore(node);
+ tpAugmentations = readTerminationPointAugmentations(node);
}
return tpAugmentations;
}
return tpAugmentations;
}
- public static List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentationFromDataStore( Node node ) {
+ public static List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentations(Node node) {
InstanceIdentifier<Node> bridgeNodeIid = MdsalHelper.createInstanceIdentifier(node.getNodeId());
Node operNode = read(LogicalDatastoreType.OPERATIONAL, bridgeNodeIid);
if(operNode != null){
return put(LogicalDatastoreType.CONFIGURATION, tpIid, tpBuilder.build());
}
- public static Boolean readTerminationPoint(Node bridgeNode, String bridgeName, String portName) {
+ public static TerminationPoint readTerminationPoint(Node bridgeNode, String bridgeName, String portName) {
InstanceIdentifier<TerminationPoint> tpIid = MdsalHelper.createTerminationPointInstanceIdentifier(
bridgeNode, portName);
- return read(LogicalDatastoreType.OPERATIONAL, tpIid) != null;
+ return read(LogicalDatastoreType.OPERATIONAL, tpIid);
}
public static Boolean addTunnelTerminationPoint(Node bridgeNode, String bridgeName, String portName, String type,
}
public static Boolean isTunnelTerminationPointExist(Node bridgeNode, String bridgeName, String portName){
- return readTerminationPoint(bridgeNode, bridgeName, portName);
+ return readTerminationPoint(bridgeNode, bridgeName, portName) != null;
}
+
public static Boolean addPatchTerminationPoint(Node node, String bridgeName, String portName, String peerPortName) {
Map<String, String> option = new HashMap<String, String>();
option.put("peer", peerPortName);
}
return ofPort;
}
+
+ public static Long getOFPort(Node bridgeNode, String portName) {
+ Long ofPort = 0L;
+ OvsdbTerminationPointAugmentation port = extractTerminationPointAugmentation(bridgeNode, portName);
+ if (port != null) {
+ ofPort = getOFPort(port);
+ } else {
+ TerminationPoint tp = readTerminationPoint(bridgeNode, null, portName);
+ if (tp != null) {
+ port = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
+ if (port != null) {
+ ofPort = getOFPort(port);
+ }
+ }
+ }
+ return ofPort;
+ }
}