mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-02 03:28:00 +00:00
WIFI-1424: OSGW refactor and cleanup com.telecominfraproject.wlan.opensync.external.integration.models
This commit is contained in:
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.vmware.ovsdb.protocol.operation.Operation;
|
||||
@@ -21,12 +20,8 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
@Component
|
||||
public class OvsdbFirmwareConfig extends OvsdbDaoBase {
|
||||
|
||||
@Autowired
|
||||
OvsdbGet ovsdbGet;
|
||||
|
||||
void configureFirmwareDownload(OvsdbClient ovsdbClient, String apId, String firmwareUrl, String firmwareVersion,
|
||||
String username, String validationCode) throws Exception {
|
||||
|
||||
try {
|
||||
LOG.debug("configureFirmwareDownload for {} to version {} url {} validationCode {} username {}", apId,
|
||||
firmwareVersion, firmwareUrl, validationCode, username);
|
||||
@@ -36,48 +31,36 @@ public class OvsdbFirmwareConfig extends OvsdbDaoBase {
|
||||
updateColumns.put("firmware_pass", new Atom<>(validationCode));
|
||||
updateColumns.put("firmware_url", new Atom<>(firmwareUrl));
|
||||
updateColumns.put("upgrade_timer", new Atom<>(upgradeTimerSeconds));
|
||||
|
||||
Row row = new Row(updateColumns);
|
||||
operations.add(new Update(awlanNodeDbTable, row));
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
for (OperationResult r : result) {
|
||||
LOG.debug("Op Result {}", r);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not download firmware {} to AP {}", firmwareVersion, apId, e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void configureFirmwareFlash(OvsdbClient ovsdbClient, String apId, String firmwareVersion, String username) {
|
||||
try {
|
||||
LOG.debug("configureFirmwareFlash on AP {} to load {} setting timer for {} seconds.", apId, firmwareVersion,
|
||||
upgradeTimerSeconds);
|
||||
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
updateColumns.put("upgrade_timer", new Atom<>(upgradeTimerSeconds));
|
||||
|
||||
Row row = new Row(updateColumns);
|
||||
operations.add(new Update(awlanNodeDbTable, row));
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
|
||||
OperationResult[] result = fResult.join();
|
||||
for (OperationResult r : result) {
|
||||
LOG.debug("Op Result {}", r);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not configure timer for flashing firmware {} on AP {}", firmwareVersion, apId, e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.CommandConfigInfo;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.Hotspot20Config;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.Hotspot20IconConfig;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.Hotspot20OsuProviders;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.InterfaceInfo;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiInetConfigInfo;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInfo;
|
||||
@@ -110,16 +109,6 @@ public class OvsdbGet extends OvsdbDaoBase {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
Map<String, InterfaceInfo> getProvisionedInterfaces(OvsdbClient ovsdbClient) {
|
||||
Map<String, InterfaceInfo> ret = new HashMap<>();
|
||||
for (Row row : getOvsdbTableRowsForCondition(ovsdbClient, interfaceDbTable, null)) {
|
||||
InterfaceInfo interfaceInfo = new InterfaceInfo(row);
|
||||
ret.put(interfaceInfo.name, interfaceInfo);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Map<String, WifiInetConfigInfo> getProvisionedWifiInetConfigs(OvsdbClient ovsdbClient) {
|
||||
Map<String, WifiInetConfigInfo> ret = new HashMap<>();
|
||||
for (Row row : getOvsdbTableRowsForCondition(ovsdbClient, wifiInetConfigDbTable, null)) {
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPInetState;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPRadioState;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
|
||||
@@ -21,72 +16,55 @@ import com.vmware.ovsdb.protocol.methods.RowUpdate;
|
||||
import com.vmware.ovsdb.protocol.methods.TableUpdate;
|
||||
import com.vmware.ovsdb.protocol.methods.TableUpdates;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Uuid;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Value;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@Component
|
||||
public class OvsdbMonitor extends OvsdbDaoBase {
|
||||
|
||||
List<OpensyncAPInetState> getInitialOpensyncApInetStateForRowUpdate(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
LOG.info("getInitialOpensyncApInetStateForRowUpdate:");
|
||||
LOG.debug("getInitialOpensyncApInetStateForRowUpdate:");
|
||||
List<OpensyncAPInetState> ret = new ArrayList<>();
|
||||
try {
|
||||
LOG.info(wifiInetStateDbTable + "_" + apId + " initial monitor table state received {}", tableUpdates);
|
||||
|
||||
LOG.debug(wifiInetStateDbTable + "_" + apId + " initial monitor table state received {}", tableUpdates);
|
||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
if (rowUpdate.getNew() != null) {
|
||||
ret.addAll(getOpensyncApInetStateForRowUpdate(rowUpdate, apId, ovsdbClient));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw (e);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
List<OpensyncAPVIFState> getInitialOpensyncApVifStateForTableUpdates(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
LOG.info("getInitialOpensyncApVifStateForTableUpdates:");
|
||||
LOG.debug("getInitialOpensyncApVifStateForTableUpdates:");
|
||||
List<OpensyncAPVIFState> ret = new ArrayList<>();
|
||||
try {
|
||||
LOG.info(wifiVifStateDbTable + "_" + apId + " initial monitor table state received {}", tableUpdates);
|
||||
|
||||
LOG.debug(wifiVifStateDbTable + "_" + apId + " initial monitor table state received {}", tableUpdates);
|
||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
if (rowUpdate.getNew() != null) {
|
||||
OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, rowUpdate.getNew());
|
||||
|
||||
ret.add(tableState);
|
||||
ret.add(new OpensyncAPVIFState(rowUpdate.getNew()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw (e);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
List<OpensyncWifiAssociatedClients> getInitialOpensyncWifiAssociatedClients(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
LOG.info("getInitialOpensyncWifiAssociatedClients:");
|
||||
LOG.debug("getInitialOpensyncWifiAssociatedClients:");
|
||||
List<OpensyncWifiAssociatedClients> ret = new ArrayList<>();
|
||||
try {
|
||||
LOG.info(wifiAssociatedClientsDbTable + "_" + apId + " initial monitor table state received {}",
|
||||
LOG.debug(wifiAssociatedClientsDbTable + "_" + apId + " initial monitor table state received {}",
|
||||
tableUpdates);
|
||||
|
||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||
@@ -97,237 +75,48 @@ public class OvsdbMonitor extends OvsdbDaoBase {
|
||||
ret.addAll(getOpensyncWifiAssociatedClients(rowUpdate, apId, ovsdbClient));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw (e);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
List<OpensyncAPInetState> getOpensyncApInetStateForRowUpdate(RowUpdate rowUpdate, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
List<OpensyncAPInetState> ret = new ArrayList<>();
|
||||
|
||||
LOG.info("OvsdbDao::getOpensyncApInetStateForRowUpdate {} for apId {}", rowUpdate, apId);
|
||||
|
||||
try {
|
||||
|
||||
Row row = rowUpdate.getNew();
|
||||
if (row == null) {
|
||||
LOG.debug("OvsdbDao::getOpensyncApInetStateForRowUpdate {} for apId {}", rowUpdate, apId);
|
||||
Row row = null;
|
||||
if (rowUpdate.getNew() != null) {
|
||||
if (rowUpdate.getOld() != null) {
|
||||
row = rowUpdate.getOld();
|
||||
row.getColumns().putAll(rowUpdate.getNew().getColumns());
|
||||
}
|
||||
|
||||
OpensyncAPInetState tableState = new OpensyncAPInetState();
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("NAT") != null)
|
||||
&& map.get("NAT").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setNat(row.getBooleanColumn("NAT"));
|
||||
}
|
||||
if ((map.get("enabled") != null)
|
||||
&& map.get("enabled").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setEnabled(row.getBooleanColumn("enabled"));
|
||||
}
|
||||
if ((map.get("if_name") != null)
|
||||
&& map.get("if_name").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfName(row.getStringColumn("if_name"));
|
||||
}
|
||||
if ((map.get("if_type") != null)
|
||||
&& map.get("if_type").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfType(row.getStringColumn("if_type"));
|
||||
}
|
||||
|
||||
if (map.containsKey("dhcpc")) {
|
||||
tableState.setDhcpc(row.getMapColumn("dhcpc"));
|
||||
}
|
||||
if (map.containsKey("dhcpd")) {
|
||||
tableState.setDhcpd(row.getMapColumn("dhcpd"));
|
||||
}
|
||||
if (map.containsKey("dns")) {
|
||||
tableState.setDns(row.getMapColumn("dns"));
|
||||
}
|
||||
if (map.get("inet_addr") != null && map.get("inet_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setInetAddr(row.getStringColumn("inet_addr"));
|
||||
}
|
||||
if (map.containsKey("netmask")) {
|
||||
tableState.setNetmask(getSingleValueFromSet(row, "netmask"));
|
||||
}
|
||||
if (map.get("vlan_id") != null
|
||||
&& map.get("vlan_id").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVlanId(row.getIntegerColumn("vlan_id").intValue());
|
||||
}
|
||||
if (map.get("gre_ifname") != null && map.get("gre_ifname").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGreIfName(row.getStringColumn("gre_ifname"));
|
||||
}
|
||||
if (map.get("gre_remote_inet_addr") != null && map.get("gre_remote_inet_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGreRemoteInetAddr(row.getStringColumn("gre_remote_inet_addr"));
|
||||
}
|
||||
if (map.get("gre_local_inet_addr") != null && map.get("gre_local_inet_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGreLocalInetAddr(row.getStringColumn("gre_local_inet_addr"));
|
||||
}
|
||||
if (map.get("gre_remote_mac_addr") != null && map.get("gre_remote_mac_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGreRemoteMacAddr(row.getStringColumn("gre_remote_mac_addr"));
|
||||
}
|
||||
|
||||
if ((map.get("ip_assign_scheme") != null) && map.get("ip_assign_scheme").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIpAssignScheme(row.getStringColumn("ip_assign_scheme"));
|
||||
}
|
||||
if ((map.get("network") != null)
|
||||
&& map.get("network").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setNetwork(row.getBooleanColumn("network"));
|
||||
}
|
||||
if ((map.get("hwaddr") != null)
|
||||
&& map.get("hwaddr").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setHwAddr(row.getStringColumn("hwaddr"));
|
||||
}
|
||||
if ((map.get("_version") != null)
|
||||
&& map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null)
|
||||
&& map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
ret.add(tableState);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not parse update for Wifi_Inet_State", e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
} else {
|
||||
row = rowUpdate.getOld();
|
||||
}
|
||||
if (row != null) {
|
||||
ret.add(new OpensyncAPInetState(row));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<OpensyncAPRadioState> getOpensyncAPRadioState(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
List<OpensyncAPRadioState> ret = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
for (Entry<String, TableUpdate> tableUpdate : tableUpdates.getTableUpdates().entrySet()) {
|
||||
|
||||
for (Entry<UUID, RowUpdate> rowUpdate : tableUpdate.getValue().getRowUpdates().entrySet()) {
|
||||
|
||||
Row row = rowUpdate.getValue().getNew();
|
||||
// Row old = rowUpdate.getOld();
|
||||
|
||||
if (row != null) {
|
||||
|
||||
OpensyncAPRadioState tableState = new OpensyncAPRadioState();
|
||||
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null) && map.get("mac").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
}
|
||||
if ((map.get("channel") != null) && map.get("channel").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setChannel(row.getIntegerColumn("channel").intValue());
|
||||
}
|
||||
if ((map.get("freq_band") != null) && map.get("freq_band").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
String frequencyBand = row.getStringColumn("freq_band");
|
||||
switch (frequencyBand) {
|
||||
case "2.4G":
|
||||
tableState.setFreqBand(RadioType.is2dot4GHz);
|
||||
break;
|
||||
case "5G":
|
||||
tableState.setFreqBand(RadioType.is5GHz);
|
||||
break;
|
||||
case "5GL":
|
||||
tableState.setFreqBand(RadioType.is5GHzL);
|
||||
break;
|
||||
case "5GU":
|
||||
tableState.setFreqBand(RadioType.is5GHzU);
|
||||
break;
|
||||
default:
|
||||
tableState.setFreqBand(RadioType.UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
if ((map.get("if_name") != null) && map.get("if_name").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfName(row.getStringColumn("if_name"));
|
||||
}
|
||||
if ((map.get("channel_mode") != null) && map.get("channel_mode").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setChannelMode(row.getStringColumn("channel_mode"));
|
||||
}
|
||||
if ((map.get("country") != null) && map.get("country").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setCountry(row.getStringColumn("country").toUpperCase());
|
||||
}
|
||||
if ((map.get("enabled") != null) && map.get("enabled").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setEnabled(row.getBooleanColumn("enabled"));
|
||||
}
|
||||
if ((map.get("ht_mode") != null) && map.get("ht_mode").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setHtMode(row.getStringColumn("ht_mode"));
|
||||
}
|
||||
if ((map.get("tx_power") != null) && map.get("tx_power").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setTxPower(row.getIntegerColumn("tx_power").intValue());
|
||||
}
|
||||
if ((map.get("hw_config") != null) && map.get("hw_config").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Map.class)) {
|
||||
tableState.setHwConfig(row.getMapColumn("hw_config"));
|
||||
}
|
||||
if ((map.get("_version") != null) && map.get("_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null) && map.get("_uuid").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
if (map.get("allowed_channels") != null) {
|
||||
|
||||
Set<Long> allowedChannels = getSet(row, "allowed_channels");
|
||||
|
||||
Set<Integer> allowed = new HashSet<>();
|
||||
for (Long channel : allowedChannels) {
|
||||
allowed.add(channel.intValue());
|
||||
}
|
||||
tableState.setAllowedChannels(allowed);
|
||||
}
|
||||
if (map.get("channels") != null) {
|
||||
|
||||
Map<String, String> channels = row.getMapColumn("channels");
|
||||
tableState.setChannels(channels);
|
||||
}
|
||||
|
||||
Set<Uuid> vifStates = row.getSetColumn("vif_states");
|
||||
tableState.setVifStates(vifStates);
|
||||
|
||||
ret.add(tableState);
|
||||
ret.add(new OpensyncAPRadioState(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret.stream().forEach(new Consumer<OpensyncAPRadioState>() {
|
||||
|
||||
@Override
|
||||
public void accept(OpensyncAPRadioState wrs) {
|
||||
LOG.debug("Wifi_Radio_State row {}", wrs);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not parse update for Wifi_Radio_State", e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -335,16 +124,13 @@ public class OvsdbMonitor extends OvsdbDaoBase {
|
||||
OvsdbClient ovsdbClient) {
|
||||
List<OpensyncAPVIFState> ret = new ArrayList<>();
|
||||
try {
|
||||
|
||||
Row row = rowUpdate.getNew(); // add/modify/init
|
||||
if (row == null) {
|
||||
row = rowUpdate.getOld(); // delete/modify
|
||||
}
|
||||
|
||||
OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, row);
|
||||
|
||||
ret.add(tableState);
|
||||
|
||||
if (row != null) {
|
||||
ret.add(new OpensyncAPVIFState(row));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not parse update for Wifi_VIF_State", e);
|
||||
throw new RuntimeException(e);
|
||||
@@ -355,271 +141,32 @@ public class OvsdbMonitor extends OvsdbDaoBase {
|
||||
|
||||
OpensyncAWLANNode getOpensyncAWLANNode(TableUpdates tableUpdates, String apId, OvsdbClient ovsdbClient) {
|
||||
OpensyncAWLANNode tableState = new OpensyncAWLANNode();
|
||||
|
||||
try {
|
||||
|
||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
Row row = rowUpdate.getNew();
|
||||
|
||||
if (row != null) {
|
||||
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if (map.get("mqtt_settings") != null) {
|
||||
tableState.setMqttSettings(row.getMapColumn("mqtt_settings"));
|
||||
}
|
||||
if (map.get("mqtt_headers") != null) {
|
||||
tableState.setMqttHeaders(row.getMapColumn("mqtt_headers"));
|
||||
}
|
||||
if (map.get("mqtt_topics") != null) {
|
||||
tableState.setMqttHeaders(row.getMapColumn("mqtt_topics"));
|
||||
}
|
||||
|
||||
if ((map.get("model") != null) && map.get("model").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setModel(row.getStringColumn("model"));
|
||||
}
|
||||
if ((map.get("sku_number") != null) && map.get("sku_number").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSkuNumber(row.getStringColumn("sku_number"));
|
||||
}
|
||||
if ((map.get("id") != null) && map.get("id").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setId(row.getStringColumn("id"));
|
||||
}
|
||||
|
||||
if (map.get("version_matrix") != null) {
|
||||
tableState.setVersionMatrix(row.getMapColumn("version_matrix"));
|
||||
}
|
||||
if ((map.get("firmware_version") != null) && map.get("firmware_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setFirmwareVersion(row.getStringColumn("firmware_version"));
|
||||
}
|
||||
if ((map.get("firmware_url") != null) && map.get("firmware_url").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setFirmwareUrl(row.getStringColumn("firmware_url"));
|
||||
}
|
||||
|
||||
if ((map.get("_uuid") != null) && map.get("_uuid").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
if ((map.get("upgrade_dl_timer") != null) && map.get("upgrade_dl_timer").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setUpgradeDlTimer(row.getIntegerColumn("upgrade_dl_timer").intValue());
|
||||
}
|
||||
if ((map.get("platform_version") != null) && map.get("platform_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setPlatformVersion(row.getStringColumn("platform_version"));
|
||||
}
|
||||
if ((map.get("firmware_pass") != null) && map.get("firmware_pass").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setFirmwarePass(row.getStringColumn("firmware_pass"));
|
||||
}
|
||||
if ((map.get("upgrade_timer") != null) && map.get("upgrade_timer").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setUpgradeTimer(row.getIntegerColumn("upgrade_timer").intValue());
|
||||
}
|
||||
if ((map.get("max_backoff") != null) && map.get("max_backoff").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMaxBackoff(row.getIntegerColumn("max_backoff").intValue());
|
||||
}
|
||||
if (map.get("led_config") != null) {
|
||||
tableState.setLedConfig(row.getMapColumn("led_config"));
|
||||
}
|
||||
if ((map.get("redirector_addr") != null) && map.get("redirector_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setRedirectorAddr(row.getStringColumn("redirector_addr"));
|
||||
}
|
||||
if ((map.get("serial_number") != null) && map.get("serial_number").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSerialNumber(row.getStringColumn("serial_number"));
|
||||
}
|
||||
if ((map.get("_version") != null) && map.get("_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
|
||||
tableState.setUpgradeStatus(row.getIntegerColumn("upgrade_status").intValue());
|
||||
|
||||
if ((map.get("device_mode") != null) && map.get("device_mode").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setDeviceMode(row.getStringColumn("device_mode"));
|
||||
}
|
||||
if ((map.get("min_backoff") != null) && map.get("min_backoff").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMinBackoff(row.getIntegerColumn("min_backoff").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("revision") != null) && map.get("revision").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setRevision(row.getStringColumn("revision"));
|
||||
}
|
||||
if ((map.get("manager_addr") != null) && map.get("manager_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setManagerAddr(row.getStringColumn("manager_addr"));
|
||||
}
|
||||
if ((map.get("factory_reset") != null) && map.get("factory_reset").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setFactoryReset(row.getBooleanColumn("factory_reset"));
|
||||
}
|
||||
tableState = new OpensyncAWLANNode(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to handle AWLAN_Node update", e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
|
||||
return tableState;
|
||||
|
||||
}
|
||||
|
||||
List<OpensyncWifiAssociatedClients> getOpensyncWifiAssociatedClients(RowUpdate rowUpdate, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
List<OpensyncWifiAssociatedClients> ret = new ArrayList<>();
|
||||
|
||||
Row row = rowUpdate.getNew();
|
||||
if (row == null) {
|
||||
row = rowUpdate.getOld();
|
||||
}
|
||||
|
||||
OpensyncWifiAssociatedClients tableState = new OpensyncWifiAssociatedClients();
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null)
|
||||
&& map.get("mac").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
if (row != null) {
|
||||
return List.of(new OpensyncWifiAssociatedClients(row));
|
||||
} else {
|
||||
return List.of();
|
||||
}
|
||||
if (row.getSetColumn("capabilities") != null) {
|
||||
tableState.setCapabilities(row.getSetColumn("capabilities"));
|
||||
}
|
||||
if ((map.get("state") != null)
|
||||
&& map.get("state").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setState(row.getStringColumn("state"));
|
||||
}
|
||||
if ((map.get("_version") != null)
|
||||
&& map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null)
|
||||
&& map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
|
||||
ret.add(tableState);
|
||||
|
||||
ret.stream().forEach(new Consumer<OpensyncWifiAssociatedClients>() {
|
||||
|
||||
@Override
|
||||
public void accept(OpensyncWifiAssociatedClients wrs) {
|
||||
LOG.debug("Wifi_Associated_Clients row {}", wrs);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
OpensyncAPVIFState processWifiVIFStateColumn(OvsdbClient ovsdbClient, Row row) {
|
||||
OpensyncAPVIFState tableState = new OpensyncAPVIFState();
|
||||
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null)
|
||||
&& map.get("mac").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
}
|
||||
if ((map.get("bridge") != null)
|
||||
&& map.get("bridge").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBridge(row.getStringColumn("bridge"));
|
||||
}
|
||||
if ((map.get("btm") != null)
|
||||
&& map.get("btm").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBtm(row.getIntegerColumn("btm").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("channel") != null)
|
||||
&& map.get("channel").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setChannel(row.getIntegerColumn("channel").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("enabled") != null)
|
||||
&& map.get("enabled").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setEnabled(row.getBooleanColumn("enabled"));
|
||||
}
|
||||
|
||||
Long ftPsk = getSingleValueFromSet(row, "ft_psk");
|
||||
if (ftPsk != null) {
|
||||
tableState.setFtPsk(ftPsk.intValue());
|
||||
}
|
||||
|
||||
Long ftMobilityDomain = getSingleValueFromSet(row, "ft_mobility_domain");
|
||||
if (ftMobilityDomain != null) {
|
||||
tableState.setFtMobilityDomain(ftMobilityDomain.intValue());
|
||||
}
|
||||
|
||||
if ((map.get("group_rekey") != null)
|
||||
&& map.get("group_rekey").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGroupRekey(row.getIntegerColumn("group_rekey").intValue());
|
||||
}
|
||||
if ((map.get("if_name") != null)
|
||||
&& map.get("if_name").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfName(row.getStringColumn("if_name"));
|
||||
}
|
||||
|
||||
if ((map.get("mode") != null)
|
||||
&& map.get("mode").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMode(row.getStringColumn("mode"));
|
||||
}
|
||||
|
||||
if ((map.get("rrm") != null)
|
||||
&& map.get("rrm").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setRrm(row.getIntegerColumn("rrm").intValue());
|
||||
}
|
||||
if ((map.get("ssid") != null)
|
||||
&& map.get("ssid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsid(row.getStringColumn("ssid"));
|
||||
}
|
||||
|
||||
if ((map.get("ssid_broadcast") != null) && map.get("ssid_broadcast").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsidBroadcast(row.getStringColumn("ssid_broadcast"));
|
||||
}
|
||||
if ((map.get("uapsd_enable") != null)
|
||||
&& map.get("uapsd_enable").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setUapsdEnable(row.getBooleanColumn("uapsd_enable"));
|
||||
}
|
||||
if ((map.get("vif_radio_idx") != null) && map.get("vif_radio_idx").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVifRadioIdx(row.getIntegerColumn("vif_radio_idx").intValue());
|
||||
}
|
||||
|
||||
List<Uuid> associatedClientsList = new ArrayList<>();
|
||||
|
||||
Set<Uuid> clients = row.getSetColumn("associated_clients");
|
||||
associatedClientsList.addAll(clients);
|
||||
|
||||
tableState.setAssociatedClients(associatedClientsList);
|
||||
|
||||
if (map.get("security") != null) {
|
||||
tableState.setSecurity(row.getMapColumn("security"));
|
||||
}
|
||||
|
||||
if ((map.get("_version") != null)
|
||||
&& map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null)
|
||||
&& map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
return tableState;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,14 +48,6 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
OvsdbGet ovsdbGet;
|
||||
|
||||
void configureGreTunnel(OvsdbClient ovsdbClient, Profile apNetworkConfiguration) {
|
||||
|
||||
// NAT false
|
||||
// if_name gre1
|
||||
// if_type gre
|
||||
// gre_local_inet_addr (Not needed): WAN IP shall be used
|
||||
// gre_remote_inet_addr <Tunnel end point IP address>
|
||||
// gre_ifname: Not needed
|
||||
|
||||
try {
|
||||
LOG.debug("Configure Gre Tunnel {}", apNetworkConfiguration);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
@@ -189,7 +181,6 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
void configureInetVifInterface(OvsdbClient ovsdbClient, String vifInterfaceName, boolean enabled,
|
||||
NetworkForwardMode networkForwardMode) {
|
||||
Map<String, WifiInetConfigInfo> inetConfigs = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||
|
||||
if (inetConfigs.containsKey(vifInterfaceName)) {
|
||||
configureInetInterface(ovsdbClient, vifInterfaceName, enabled, "vif", true,
|
||||
(networkForwardMode == NetworkForwardMode.NAT));
|
||||
@@ -209,44 +200,28 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
|
||||
void createVlanInterfaceInGreTunnel(OvsdbClient ovsdbClient, int vlanId, String greTunnel) {
|
||||
try {
|
||||
|
||||
// if_name gre_<vlan id>
|
||||
// if_type vlan
|
||||
// parent_ifname gre
|
||||
// vlan_id <vlan id>
|
||||
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> tableColumns = new HashMap<>();
|
||||
|
||||
Map<String, WifiInetConfigInfo> inetConfigMap = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||
|
||||
WifiInetConfigInfo parentTunnel = inetConfigMap.get(greTunnel);
|
||||
if (parentTunnel == null) {
|
||||
throw new RuntimeException("Cannot get tunnel interface " + parentTunnel + " for vlan " + vlanId);
|
||||
}
|
||||
|
||||
tableColumns = new HashMap<>();
|
||||
|
||||
tableColumns.put("if_type", new Atom<>("bridge"));
|
||||
tableColumns.put("vlan_id", new Atom<>(vlanId));
|
||||
tableColumns.put("if_name", new Atom<>(parentTunnel.ifName + "_" + Integer.toString(vlanId)));
|
||||
tableColumns.put("parent_ifname", new Atom<>(parentTunnel.ifName));
|
||||
tableColumns.put("enabled", new Atom<>(true));
|
||||
tableColumns.put("network", new Atom<>(true));
|
||||
|
||||
Row row = new Row(tableColumns);
|
||||
|
||||
operations.add(new Insert(wifiInetConfigDbTable, row));
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
for (OperationResult res : result) {
|
||||
|
||||
if (res instanceof InsertResult) {
|
||||
LOG.info("createVlanNetworkInterfaces {}", ((InsertResult) res).toString());
|
||||
} else if (res instanceof UpdateResult) {
|
||||
|
||||
LOG.info("createVlanNetworkInterfaces {}", ((UpdateResult) res).toString());
|
||||
} else if (res instanceof ErrorResult) {
|
||||
LOG.error("createVlanNetworkInterfaces error {}", (res));
|
||||
@@ -254,12 +229,9 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
+ ((ErrorResult) res).getDetails());
|
||||
}
|
||||
}
|
||||
|
||||
inetConfigMap = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||
|
||||
LOG.debug("Provisioned vlan on greTunnel {}",
|
||||
inetConfigMap.get(parentTunnel.ifName + "_" + Integer.toString(vlanId)));
|
||||
|
||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||
LOG.error("Error in provisioning Vlan", e);
|
||||
throw new RuntimeException(e);
|
||||
@@ -269,18 +241,14 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
|
||||
void createVlanNetworkInterfaces(OvsdbClient ovsdbClient, int vlanId) {
|
||||
try {
|
||||
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> tableColumns = new HashMap<>();
|
||||
|
||||
Map<String, WifiInetConfigInfo> inetConfigMap = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||
|
||||
WifiInetConfigInfo parentLanInterface = inetConfigMap.get(defaultLanInterfaceName);
|
||||
if (parentLanInterface == null) {
|
||||
throw new RuntimeException(
|
||||
"Cannot get lan interface " + defaultLanInterfaceName + " for vlan " + vlanId);
|
||||
}
|
||||
|
||||
tableColumns.put("if_type", new Atom<>("vlan"));
|
||||
tableColumns.put("vlan_id", new Atom<>(vlanId));
|
||||
tableColumns.put("if_name", new Atom<>(parentLanInterface.ifName + "_" + Integer.toString(vlanId)));
|
||||
@@ -290,33 +258,26 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
tableColumns.put("ip_assign_scheme", new Atom<>(parentLanInterface.ipAssignScheme));
|
||||
tableColumns.put("NAT", new Atom<>(parentLanInterface.nat));
|
||||
tableColumns.put("mtu", new Atom<>(1500));
|
||||
|
||||
String[] inetAddress = parentLanInterface.inetAddr.split("\\.");
|
||||
String vlanAddress = inetAddress[0] + "." + inetAddress[1] + "." + vlanId + "." + inetAddress[3];
|
||||
tableColumns.put("inet_addr", new Atom<>(vlanAddress));
|
||||
tableColumns.put("netmask", new Atom<>(parentLanInterface.netmask));
|
||||
tableColumns.put("dhcpd", com.vmware.ovsdb.protocol.operation.notation.Map.of(parentLanInterface.dhcpd));
|
||||
|
||||
Row row = new Row(tableColumns);
|
||||
|
||||
if (inetConfigMap.containsKey(parentLanInterface.ifName + "_" + Integer.toString(vlanId))) {
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
conditions.add(new Condition("vlan_id", Function.EQUALS, new Atom<>(vlanId)));
|
||||
conditions.add(new Condition("parent_ifname", Function.EQUALS, new Atom<>(parentLanInterface.ifName)));
|
||||
|
||||
operations.add(new Update(wifiInetConfigDbTable, conditions, row));
|
||||
} else {
|
||||
operations.add(new Insert(wifiInetConfigDbTable, row));
|
||||
}
|
||||
|
||||
WifiInetConfigInfo parentWanInterface = inetConfigMap.get(defaultWanInterfaceName);
|
||||
if (parentWanInterface == null) {
|
||||
throw new RuntimeException(
|
||||
"Cannot get wan interface " + defaultWanInterfaceName + " for vlan " + vlanId);
|
||||
}
|
||||
|
||||
tableColumns = new HashMap<>();
|
||||
|
||||
tableColumns.put("if_type", new Atom<>("vlan"));
|
||||
tableColumns.put("vlan_id", new Atom<>(vlanId));
|
||||
tableColumns.put("if_name", new Atom<>(parentWanInterface.ifName + "_" + Integer.toString(vlanId)));
|
||||
@@ -325,11 +286,8 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
tableColumns.put("network", new Atom<>(true));
|
||||
tableColumns.put("ip_assign_scheme", new Atom<>(parentWanInterface.ipAssignScheme));
|
||||
tableColumns.put("NAT", new Atom<>(parentWanInterface.nat));
|
||||
|
||||
tableColumns.put("mtu", new Atom<>(1500));
|
||||
|
||||
row = new Row(tableColumns);
|
||||
|
||||
if (inetConfigMap.containsKey(parentWanInterface.ifName + "_" + Integer.toString(vlanId))) {
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
conditions.add(new Condition("vlan_id", Function.EQUALS, new Atom<>(vlanId)));
|
||||
@@ -337,16 +295,12 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
} else {
|
||||
operations.add(new Insert(wifiInetConfigDbTable, row));
|
||||
}
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
for (OperationResult res : result) {
|
||||
|
||||
if (res instanceof InsertResult) {
|
||||
LOG.info("createVlanNetworkInterfaces {}", ((InsertResult) res).toString());
|
||||
} else if (res instanceof UpdateResult) {
|
||||
|
||||
LOG.info("createVlanNetworkInterfaces {}", ((UpdateResult) res).toString());
|
||||
} else if (res instanceof ErrorResult) {
|
||||
LOG.error("createVlanNetworkInterfaces error {}", (res));
|
||||
@@ -354,18 +308,14 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
+ ((ErrorResult) res).getDetails());
|
||||
}
|
||||
}
|
||||
|
||||
inetConfigMap = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||
|
||||
LOG.debug("Provisioned vlan on wan {} and lan {}",
|
||||
inetConfigMap.get(parentWanInterface.ifName + "_" + Integer.toString(vlanId)),
|
||||
inetConfigMap.get(parentLanInterface.ifName + "_" + Integer.toString(vlanId)));
|
||||
|
||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||
LOG.error("Error in provisioning Vlan", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void createVlanNetworkInterfaces(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
||||
@@ -377,25 +327,19 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
}
|
||||
}
|
||||
for (Integer vlanId : vlans) {
|
||||
|
||||
Optional<GreTunnelConfiguration> tunnelConfiguration = ((ApNetworkConfiguration) opensyncApConfig
|
||||
.getApProfile().getDetails()).getGreTunnelConfigurations().stream()
|
||||
.filter(new Predicate<GreTunnelConfiguration>() {
|
||||
|
||||
@Override
|
||||
public boolean test(GreTunnelConfiguration t) {
|
||||
|
||||
return t.getVlanIdsInGreTunnel().contains(vlanId);
|
||||
}
|
||||
|
||||
}).findFirst();
|
||||
|
||||
if (tunnelConfiguration.isPresent()) {
|
||||
createVlanInterfaceInGreTunnel(ovsdbClient, vlanId, tunnelConfiguration.get().getGreTunnelName());
|
||||
} else {
|
||||
createVlanNetworkInterfaces(ovsdbClient, vlanId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,9 +349,7 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
.getProvisionedWifiInetConfigs(ovsdbClient).values();
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
|
||||
for (WifiInetConfigInfo wifiInetConfigInfo : provisionedWifiInetConfigs) {
|
||||
|
||||
if (wifiInetConfigInfo.vlanId > 1 || wifiInetConfigInfo.ifType.equals("vif")
|
||||
|| wifiInetConfigInfo.ifName.startsWith("gre") || wifiInetConfigInfo.ifType.equals("gre")) {
|
||||
conditions = new ArrayList<>();
|
||||
@@ -417,21 +359,16 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
}
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
LOG.info("Removed all existing vif, vlan, and gre interface configs from {}:", wifiInetConfigDbTable);
|
||||
|
||||
for (OperationResult res : result) {
|
||||
LOG.info("Op Result {}", res);
|
||||
}
|
||||
|
||||
provisionedWifiInetConfigs = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient).values();
|
||||
|
||||
for (WifiInetConfigInfo inetConfigInfo : provisionedWifiInetConfigs) {
|
||||
if (inetConfigInfo.ifType.equals("vif") || inetConfigInfo.ifType.equals("gre")) {
|
||||
throw new RuntimeException(
|
||||
"Failed to remove all vif and gre interface configurations from Wifi_Inet_Config dbTable, still has "
|
||||
+ provisionedWifiInetConfigs.stream().filter(new Predicate<WifiInetConfigInfo>() {
|
||||
|
||||
@Override
|
||||
public boolean test(WifiInetConfigInfo t) {
|
||||
if ((t.ifType.equals("vif")) || (t.ifType.equals("gre"))) {
|
||||
@@ -439,17 +376,13 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||
LOG.error("Error in removeAllInetConfigs", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user