use of org.batfish.representation.juniper.NodeDevice in project batfish by batfish.
the class ConfigurationBuilder method enterInt_named.
@Override
public void enterInt_named(Int_namedContext ctx) {
Interface currentInterface;
if (ctx.interface_id() == null) {
currentInterface = _configuration.getGlobalMasterInterface();
} else {
String ifaceName = getInterfaceName(ctx.interface_id());
Map<String, Interface> interfaces;
String nodeDevicePrefix = "";
if (ctx.interface_id().node == null) {
interfaces = _configuration.getInterfaces();
} else {
String nodeDeviceName = ctx.interface_id().node.getText();
nodeDevicePrefix = nodeDeviceName + ":";
NodeDevice nodeDevice = _configuration.getNodeDevices().computeIfAbsent(nodeDeviceName, NodeDevice::new);
interfaces = nodeDevice.getInterfaces();
}
currentInterface = interfaces.get(ifaceName);
if (currentInterface == null) {
String fullIfaceName = nodeDevicePrefix + ifaceName;
int definitionLine = ctx.interface_id().getStart().getLine();
currentInterface = new Interface(fullIfaceName, definitionLine);
currentInterface.setRoutingInstance(_currentRoutingInstance.getName());
currentInterface.setParent(_configuration.getGlobalMasterInterface());
interfaces.put(fullIfaceName, currentInterface);
}
}
_currentInterface = currentInterface;
_currentMasterInterface = currentInterface;
}
use of org.batfish.representation.juniper.NodeDevice in project batfish by batfish.
the class ConfigurationBuilder method initInterface.
private Interface initInterface(Interface_idContext id) {
String currentRoutingInstance = _currentRoutingInstance.getName();
Map<String, Interface> interfaces;
if (id.node != null) {
String nodeDeviceName = id.node.getText();
NodeDevice nodeDevice = _configuration.getNodeDevices().computeIfAbsent(nodeDeviceName, NodeDevice::new);
interfaces = nodeDevice.getInterfaces();
} else {
interfaces = _configuration.getInterfaces();
}
String name = getInterfaceName(id);
int definitionLine = id.name.getLine();
String unit = null;
if (id.unit != null) {
unit = id.unit.getText();
definitionLine = id.unit.getLine();
}
String unitFullName = name + "." + unit;
Interface iface = interfaces.get(name);
if (iface == null) {
iface = new Interface(name, definitionLine);
iface.setRoutingInstance(currentRoutingInstance);
interfaces.put(name, iface);
}
if (unit != null) {
Map<String, Interface> units = iface.getUnits();
iface = units.get(unitFullName);
if (iface == null) {
iface = new Interface(unitFullName, definitionLine);
iface.setRoutingInstance(currentRoutingInstance);
units.put(unitFullName, iface);
}
}
return iface;
}
Aggregations