change to use 1st ethernet for WAN, or to use bridge for LAN

This commit is contained in:
Mike Hansen
2020-06-26 17:44:57 -04:00
parent 5ee0eface5
commit e64d8488bb

View File

@@ -96,7 +96,7 @@ public class OvsdbDao {
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_lan:br-lan}") @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_lan:br-lan}")
public String defaultLanIfName; public String defaultLanIfName;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_wan:eth1}") @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_wan:eth}")
public String defaultWanIfName; public String defaultWanIfName;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio1:home-ap-24}") @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio1:home-ap-24}")
@@ -174,7 +174,7 @@ public class OvsdbDao {
// now populate macAddress, ipV4Address from Wifi_Inet_State // now populate macAddress, ipV4Address from Wifi_Inet_State
// first look them up for if_name = br-wan // first look them up for if_name = br-wan
fillInIpAddressAndMac(ovsdbClient, ret, defaultWanIfName); getIpAddressAndMacForEth(ovsdbClient, ret, defaultWanIfName);
if (ret.ipV4Address == null || ret.macAddress == null) { if (ret.ipV4Address == null || ret.macAddress == null) {
// when not found - look them up for if_name = br-lan // when not found - look them up for if_name = br-lan
fillInIpAddressAndMac(ovsdbClient, ret, defaultLanIfName); fillInIpAddressAndMac(ovsdbClient, ret, defaultLanIfName);
@@ -322,6 +322,49 @@ public class OvsdbDao {
return allowedChannels; return allowedChannels;
} }
public void getIpAddressAndMacForEth(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifType) {
try {
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
List<String> columns = new ArrayList<>();
// populate macAddress, ipV4Address from Wifi_Inet_State
columns.add("inet_addr");
columns.add("hwaddr");
columns.add("if_type");
columns.add("if_name");
conditions.add(new Condition("if_type", Function.EQUALS, new Atom<>(ifType)));
operations.add(new Select(wifiInetStateDbTable, conditions, columns));
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
if (LOG.isDebugEnabled()) {
LOG.debug("Select from {}:", wifiInetStateDbTable);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
}
Row row = null;
if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) {
row = ((SelectResult) result[0]).getRows().iterator().next();
connectNodeInfo.ipV4Address = getSingleValueFromSet(row, "inet_addr");
connectNodeInfo.ifName = row.getStringColumn("if_name");
connectNodeInfo.ifType = getSingleValueFromSet(row, "if_type");
connectNodeInfo.macAddress = getSingleValueFromSet(row, "hwaddr");
}
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
}
public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifName) { public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifName) {
try { try {
@@ -2154,16 +2197,7 @@ public class OvsdbDao {
List<RadioType> enabledRadiosFromAp = new ArrayList<>(); List<RadioType> enabledRadiosFromAp = new ArrayList<>();
getEnabledRadios(ovsdbClient, enabledRadiosFromAp); getEnabledRadios(ovsdbClient, enabledRadiosFromAp);
Set<String> inetIfs = getProvisionedWifiInetConfigs(ovsdbClient).keySet(); bridgeNameVifInterfaces = getConnectNodeInfo(ovsdbClient).ifName;
if (inetIfs.contains(defaultWanIfName)) {
bridgeNameVifInterfaces = defaultWanIfName;
} else if (inetIfs.contains(defaultLanIfName)) {
bridgeNameVifInterfaces = defaultLanIfName;
} else {
LOG.error("Cannot provision a VIF without either LAN or WAN interface on AP");
return;
}
for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) { for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) {