mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-12-22 13:17:05 +00:00
OpensyncGateway changes to only treat clients which appear in
Wifi_Associated_Clients table as clients which can be added to the cloud's client and client session lists. Other changes through either stats changes or via other tables in ovsdb can only alter existing clients and sessions. Else they are ignored. SSIDs and InetConfig for SSIDs are not automatically deleted if an existing configuration for this AP containing profiles for the ssids exists on the cloud.
This commit is contained in:
@@ -1228,10 +1228,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||||
|
|
||||||
if (LOG.isTraceEnabled()) {
|
LOG.info("Processing Wifi_VIF_State table update for AP {}, updated ACTIVE_BSSID Status {}", apId,
|
||||||
LOG.trace("Processing Wifi_VIF_State table update for AP {}, updated ACTIVE_BSSID Status {}", apId,
|
activeBssidsStatus);
|
||||||
activeBssidsStatus.toPrettyString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1415,9 +1414,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
isReassociation = false;
|
isReassociation = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
ClientInfoDetails clientDetails = (ClientInfoDetails) clientInstance.getDetails();
|
|
||||||
|
|
||||||
clientInstance.setDetails(clientDetails);
|
|
||||||
|
|
||||||
clientInstance = clientServiceInterface.update(clientInstance);
|
clientInstance = clientServiceInterface.update(clientInstance);
|
||||||
|
|
||||||
@@ -1432,16 +1428,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
clientSession.setLocationId(ce.getLocationId());
|
clientSession.setLocationId(ce.getLocationId());
|
||||||
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
|
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
|
||||||
clientSessionDetails.setIsReassociation(isReassociation);
|
clientSessionDetails.setIsReassociation(isReassociation);
|
||||||
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
|
|
||||||
clientSession.setDetails(clientSessionDetails);
|
clientSession.setDetails(clientSessionDetails);
|
||||||
|
|
||||||
clientSession = clientServiceInterface.updateSession(clientSession);
|
clientSession = clientServiceInterface.updateSession(clientSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientSessionDetails clientSessionDetails = clientSession.getDetails();
|
ClientSessionDetails clientSessionDetails = clientSession.getDetails();
|
||||||
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
|
clientSessionDetails.setAssociationState(AssociationState._802_11_Associated);
|
||||||
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
|
clientSessionDetails.setAssocTimestamp(System.currentTimeMillis());
|
||||||
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
|
|
||||||
clientSession.getDetails().mergeSession(clientSessionDetails);
|
clientSession.getDetails().mergeSession(clientSessionDetails);
|
||||||
|
|
||||||
clientSession = clientServiceInterface.updateSession(clientSession);
|
clientSession = clientServiceInterface.updateSession(clientSession);
|
||||||
@@ -1772,29 +1765,29 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<MacAddress> macAddressSet = new HashSet<>();
|
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
|
||||||
macAddressSet.add(new MacAddress(deletedClientMac));
|
new MacAddress(deletedClientMac));
|
||||||
List<ClientSession> clientSessionList = clientServiceInterface.getSessions(customerId, macAddressSet);
|
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
|
||||||
|
new MacAddress(deletedClientMac));
|
||||||
|
|
||||||
for (ClientSession session : clientSessionList) {
|
if (client != null) {
|
||||||
|
if (clientSession != null) {
|
||||||
|
if (!clientSession.getDetails().getAssociationState().equals(AssociationState.Disconnected)) {
|
||||||
|
clientSession.getDetails().setAssociationState(AssociationState.Disconnected);
|
||||||
|
clientSession = clientServiceInterface.updateSession(clientSession);
|
||||||
|
LOG.info("Session {} for client {} is now disconnected.", clientSession, client.getMacAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (clientSession != null) {
|
||||||
|
|
||||||
ClientSessionDetails clientSessionDetails = session.getDetails();
|
clientSession = clientServiceInterface.deleteSession(customerId, equipmentId,
|
||||||
|
new MacAddress(deletedClientMac));
|
||||||
|
|
||||||
if ((clientSessionDetails.getAssociationState() != null)
|
LOG.info("No client {} found, delete session {}", new MacAddress(deletedClientMac), clientSession);
|
||||||
&& !clientSessionDetails.getAssociationState().equals(AssociationState.Disconnected)) {
|
|
||||||
clientSessionDetails.setDisconnectByClientTimestamp(System.currentTimeMillis());
|
|
||||||
clientSessionDetails.setAssociationState(AssociationState.Disconnected);
|
|
||||||
|
|
||||||
session.setDetails(clientSessionDetails);
|
|
||||||
session = clientServiceInterface.updateSession(session);
|
|
||||||
|
|
||||||
if (LOG.isTraceEnabled()) {
|
|
||||||
LOG.trace("wifiAssociatedClientsDbTableDelete Updated client session, set to disconnected {}",
|
|
||||||
session.toPrettyString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1839,13 +1832,17 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
|
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
|
||||||
if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
|
|
||||||
|
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
|
||||||
|
clientMacAddress);
|
||||||
|
|
||||||
|
if (client == null) {
|
||||||
|
LOG.info("Cannot find client instance for {}", clientMacAddress);
|
||||||
|
continue;
|
||||||
|
} else if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
|
||||||
LOG.info("Not a client device {} ", dhcpLeasedIps);
|
LOG.info("Not a client device {} ", dhcpLeasedIps);
|
||||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface
|
|
||||||
.getOrNull(customerId, clientMacAddress);
|
|
||||||
if (client != null) {
|
|
||||||
|
|
||||||
// In case somehow this equipment has accidentally been
|
// In case somehow this equipment has accidentally been
|
||||||
// tagged as a client, remove
|
// tagged as a client, remove
|
||||||
@@ -1858,15 +1855,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
|
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Deleting invalid client {}",
|
LOG.info("Deleting invalid client {}", clientServiceInterface.delete(customerId, clientMacAddress));
|
||||||
clientServiceInterface.delete(customerId, clientMacAddress));
|
|
||||||
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
|
|
||||||
clientMacAddress);
|
|
||||||
if (client != null) {
|
|
||||||
LOG.info("Client {} already exists on the cloud, update client values", dhcpLeasedIps);
|
LOG.info("Client {} already exists on the cloud, update client values", dhcpLeasedIps);
|
||||||
|
|
||||||
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
|
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
|
||||||
@@ -1902,6 +1895,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
// In this case, we might have a session, as the client
|
// In this case, we might have a session, as the client
|
||||||
// already exists on the cloud, update if required
|
// already exists on the cloud, update if required
|
||||||
|
|
||||||
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
|
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
|
||||||
clientMacAddress);
|
clientMacAddress);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
@@ -1909,15 +1903,61 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!clientSessionList.isEmpty()) {
|
||||||
|
LOG.info("Updating client sessions {}", clientSessionList);
|
||||||
|
clientSessionList = clientServiceInterface.updateSessions(clientSessionList);
|
||||||
|
LOG.info("Updated client sessions {}", clientSessionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (rowUpdateOperation.equals(RowUpdateOperation.MODIFY)
|
||||||
|
|| rowUpdateOperation.equals(RowUpdateOperation.INIT)) {
|
||||||
|
|
||||||
|
List<ClientSession> clientSessionList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map<String, String> dhcpLeasedIps : dhcpAttributes) {
|
||||||
|
|
||||||
|
if (!dhcpLeasedIps.containsKey("hwaddr")) {
|
||||||
|
|
||||||
|
LOG.info("Cannot update a client {} that has no hwaddr.", dhcpLeasedIps);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
|
||||||
|
|
||||||
|
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
|
||||||
|
clientMacAddress);
|
||||||
|
if (client == null) {
|
||||||
|
LOG.info("Cannot find client instance for {}", clientMacAddress);
|
||||||
|
continue;
|
||||||
|
} else if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
|
||||||
|
|
||||||
|
LOG.info("Not a client device {} ", dhcpLeasedIps);
|
||||||
|
|
||||||
|
|
||||||
|
// In case somehow this equipment has accidentally been
|
||||||
|
// tagged as a client, remove
|
||||||
|
|
||||||
|
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
|
||||||
|
clientMacAddress);
|
||||||
|
|
||||||
|
if (clientSession != null) {
|
||||||
|
LOG.info("Deleting invalid client session {}",
|
||||||
|
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("Deleting invalid client {}", clientServiceInterface.delete(customerId, clientMacAddress));
|
||||||
|
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
client = new com.telecominfraproject.wlan.client.models.Client();
|
|
||||||
|
|
||||||
client.setCustomerId(customerId);
|
|
||||||
client.setMacAddress(clientMacAddress);
|
|
||||||
|
|
||||||
ClientInfoDetails clientDetails = new ClientInfoDetails();
|
|
||||||
|
|
||||||
|
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
|
||||||
if (dhcpLeasedIps.containsKey("hostname")) {
|
if (dhcpLeasedIps.containsKey("hostname")) {
|
||||||
|
|
||||||
clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
|
clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
|
||||||
@@ -1944,109 +1984,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
client.setDetails(clientDetails);
|
client.setDetails(clientDetails);
|
||||||
|
|
||||||
client = clientServiceInterface.create(client);
|
|
||||||
|
|
||||||
LOG.info("Created Client {}.", client);
|
|
||||||
}
|
|
||||||
|
|
||||||
// we might have a session, update if required
|
|
||||||
ClientSession session = updateClientSession(customerId, equipmentId, locationId, dhcpLeasedIps,
|
|
||||||
clientMacAddress);
|
|
||||||
if (session != null) {
|
|
||||||
clientSessionList.add(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientSessionList.isEmpty()) {
|
|
||||||
LOG.info("Updating client sessions {}", clientSessionList);
|
|
||||||
clientSessionList = clientServiceInterface.updateSessions(clientSessionList);
|
|
||||||
LOG.info("Updated client sessions {}", clientSessionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (rowUpdateOperation.equals(RowUpdateOperation.MODIFY)
|
|
||||||
|| rowUpdateOperation.equals(RowUpdateOperation.INIT)) {
|
|
||||||
|
|
||||||
List<ClientSession> clientSessionList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Map<String, String> dhcpLeasedIps : dhcpAttributes) {
|
|
||||||
|
|
||||||
if (!dhcpLeasedIps.containsKey("hwaddr")) {
|
|
||||||
|
|
||||||
LOG.info("Cannot update a client {} that has no hwaddr.", dhcpLeasedIps);
|
|
||||||
continue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr"));
|
|
||||||
|
|
||||||
if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
|
|
||||||
|
|
||||||
LOG.info("Not a client device {} ", dhcpLeasedIps);
|
|
||||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface
|
|
||||||
.getOrNull(customerId, clientMacAddress);
|
|
||||||
if (client != null) {
|
|
||||||
|
|
||||||
// In case somehow this equipment has accidentally been
|
|
||||||
// tagged as a client, remove
|
|
||||||
|
|
||||||
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
|
|
||||||
clientMacAddress);
|
|
||||||
|
|
||||||
if (clientSession != null) {
|
|
||||||
LOG.info("Deleting invalid client session {}",
|
|
||||||
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.info("Deleting invalid client {}",
|
|
||||||
clientServiceInterface.delete(customerId, clientMacAddress));
|
|
||||||
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId,
|
|
||||||
clientMacAddress);
|
|
||||||
if (client == null) {
|
|
||||||
LOG.info("Client {} does not exist on the cloud. Creating...", dhcpLeasedIps);
|
|
||||||
client = new com.telecominfraproject.wlan.client.models.Client();
|
|
||||||
client.setCustomerId(customerId);
|
|
||||||
client.setMacAddress(clientMacAddress);
|
|
||||||
ClientInfoDetails clientDetails = new ClientInfoDetails();
|
|
||||||
|
|
||||||
client.setDetails(clientDetails);
|
|
||||||
|
|
||||||
client = clientServiceInterface.create(client);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientInfoDetails clientDetails = (ClientInfoDetails) client.getDetails();
|
|
||||||
if (dhcpLeasedIps.containsKey("hostname")) {
|
|
||||||
|
|
||||||
clientDetails.setHostName(dhcpLeasedIps.get("hostname"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dhcpLeasedIps.containsKey("fingerprint")) {
|
|
||||||
|
|
||||||
clientDetails.setApFingerprint(dhcpLeasedIps.get("fingerprint"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dhcpLeasedIps.containsKey("device_type")) {
|
|
||||||
|
|
||||||
DhcpFpDeviceType dhcpFpDeviceType = DhcpFpDeviceType.getByName(dhcpLeasedIps.get("device_type"));
|
|
||||||
ClientType clientType = OvsdbToWlanCloudTypeMappingUtility
|
|
||||||
.getClientTypeForDhcpFpDeviceType(dhcpFpDeviceType);
|
|
||||||
|
|
||||||
LOG.debug("Translate from ovsdb {} to cloud {}", dhcpFpDeviceType, clientType);
|
|
||||||
|
|
||||||
clientDetails.setClientType(clientType.getId());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
client.setDetails(clientDetails);
|
|
||||||
|
|
||||||
client = clientServiceInterface.update(client);
|
client = clientServiceInterface.update(client);
|
||||||
|
|
||||||
LOG.info("Updated Client {}.", client);
|
LOG.info("Updated Client {}.", client);
|
||||||
@@ -2059,6 +1996,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
clientSessionList.add(session);
|
clientSessionList.add(session);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2096,7 +2034,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
// "manuf_id":
|
// "manuf_id":
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
session = new ClientSession();
|
return null;
|
||||||
}
|
}
|
||||||
session.setCustomerId(customerId);
|
session.setCustomerId(customerId);
|
||||||
session.setEquipmentId(equipmentId);
|
session.setEquipmentId(equipmentId);
|
||||||
|
|||||||
@@ -1891,8 +1891,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleClientSessionMetricsUpdate(int customerId, long equipmentId, long locationId, RadioType radioType,
|
ClientSession handleClientSessionMetricsUpdate(int customerId, long equipmentId, long locationId,
|
||||||
long timestamp, sts.OpensyncStats.Client client) {
|
RadioType radioType, long timestamp, sts.OpensyncStats.Client client) {
|
||||||
try
|
try
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -1904,13 +1904,10 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
|
|
||||||
boolean isReassociation = true;
|
boolean isReassociation = true;
|
||||||
if (clientInstance == null) {
|
if (clientInstance == null) {
|
||||||
clientInstance = new com.telecominfraproject.wlan.client.models.Client();
|
|
||||||
clientInstance.setCustomerId(customerId);
|
|
||||||
clientInstance.setMacAddress(new MacAddress(client.getMacAddress()));
|
|
||||||
clientInstance.setDetails(new ClientInfoDetails());
|
|
||||||
clientInstance = clientServiceInterface.create(clientInstance);
|
|
||||||
|
|
||||||
isReassociation = false;
|
LOG.info("Cannot get client instance for {}", client.getMacAddress());
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Client {}", clientInstance);
|
LOG.info("Client {}", clientInstance);
|
||||||
@@ -1919,18 +1916,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
clientInstance.getMacAddress());
|
clientInstance.getMacAddress());
|
||||||
|
|
||||||
if (clientSession == null) {
|
if (clientSession == null) {
|
||||||
|
LOG.info("Cannot get client session for {}", clientInstance.getMacAddress());
|
||||||
clientSession = new ClientSession();
|
return null;
|
||||||
clientSession.setCustomerId(customerId);
|
|
||||||
clientSession.setEquipmentId(equipmentId);
|
|
||||||
clientSession.setLocationId(locationId);
|
|
||||||
clientSession.setMacAddress(clientInstance.getMacAddress());
|
|
||||||
ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
|
|
||||||
clientSessionDetails.setSsid(client.getSsid());
|
|
||||||
clientSessionDetails.setRadioType(radioType);
|
|
||||||
clientSessionDetails.setSessionId(clientInstance.getMacAddress().getAddressAsLong());
|
|
||||||
clientSession.setDetails(new ClientSessionDetails());
|
|
||||||
clientSession = clientServiceInterface.updateSession(clientSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientSessionDetails latestClientSessionDetails = clientSession.getDetails();
|
ClientSessionDetails latestClientSessionDetails = clientSession.getDetails();
|
||||||
@@ -1961,7 +1948,6 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
if (!ssidConfigList.isEmpty()) {
|
if (!ssidConfigList.isEmpty()) {
|
||||||
|
|
||||||
Profile ssidProfile = ssidConfigList.iterator().next();
|
Profile ssidProfile = ssidConfigList.iterator().next();
|
||||||
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
|
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
|
||||||
if (ssidConfig.getSecureMode().equals(SecureMode.open)) {
|
if (ssidConfig.getSecureMode().equals(SecureMode.open)) {
|
||||||
@@ -1979,7 +1965,6 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2EAP)
|
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2EAP)
|
||||||
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2OnlyEAP)) {
|
|| ssidConfig.getSecureMode().equals(SecureMode.wpa2OnlyEAP)) {
|
||||||
latestClientSessionDetails.setSecurityType(SecurityType.RADIUS);
|
latestClientSessionDetails.setSecurityType(SecurityType.RADIUS);
|
||||||
|
|
||||||
latestClientSessionDetails.setEapDetails(new ClientEapDetails());
|
latestClientSessionDetails.setEapDetails(new ClientEapDetails());
|
||||||
} else {
|
} else {
|
||||||
latestClientSessionDetails.setSecurityType(SecurityType.UNSUPPORTED);
|
latestClientSessionDetails.setSecurityType(SecurityType.UNSUPPORTED);
|
||||||
@@ -2009,9 +1994,11 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
|
|
||||||
LOG.debug("Updated client session {}", clientSession);
|
LOG.debug("Updated client session {}", clientSession);
|
||||||
|
|
||||||
|
return clientSession;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error while attempting to create ClientSession and Info", e);
|
LOG.error("Error while attempting to create ClientSession and Info", e);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientSessionMetricDetails calculateClientSessionMetricDetails(sts.OpensyncStats.Client client, long timestamp) {
|
ClientSessionMetricDetails calculateClientSessionMetricDetails(sts.OpensyncStats.Client client, long timestamp) {
|
||||||
@@ -2134,9 +2121,11 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
|
|||||||
|
|
||||||
if (client.hasConnected() && client.getConnected() && client.hasMacAddress()) {
|
if (client.hasConnected() && client.getConnected() && client.hasMacAddress()) {
|
||||||
// update metrics for connected client
|
// update metrics for connected client
|
||||||
numConnectedClients += 1;
|
ClientSession session = handleClientSessionMetricsUpdate(customerId, equipmentId, locationId, radioType,
|
||||||
handleClientSessionMetricsUpdate(customerId, equipmentId, locationId, radioType,
|
|
||||||
clientReport.getTimestampMs(), client);
|
clientReport.getTimestampMs(), client);
|
||||||
|
if (session != null) {
|
||||||
|
numConnectedClients += 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make sure, if we have a session for this client,
|
// Make sure, if we have a session for this client,
|
||||||
// it
|
// it
|
||||||
|
|||||||
@@ -193,14 +193,15 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
LOG.debug("Client {} connect for AP {}", clientCn, apId);
|
LOG.debug("Client {} connect for AP {}", clientCn, apId);
|
||||||
|
|
||||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
|
||||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
|
||||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
|
||||||
|
|
||||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||||
|
|
||||||
if (opensyncAPConfig != null) {
|
if (opensyncAPConfig != null) {
|
||||||
|
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||||
|
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||||
|
ovsdbDao.removeAllSsids(ovsdbClient, opensyncAPConfig); // always
|
||||||
|
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||||
@@ -210,10 +211,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
if (((ApNetworkConfiguration) opensyncAPConfig.getApProfile().getDetails()).getSyntheticClientEnabled()) {
|
if (((ApNetworkConfiguration) opensyncAPConfig.getApProfile().getDetails()).getSyntheticClientEnabled()) {
|
||||||
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
|
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||||
|
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||||
|
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||||
|
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
|
||||||
|
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
||||||
}
|
}
|
||||||
@@ -262,18 +266,18 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||||
|
ovsdbDao.removeAllSsids(ovsdbClient, opensyncAPConfig); // always
|
||||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||||
|
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||||
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
||||||
}
|
}
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
|
||||||
|
|
||||||
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
||||||
@@ -507,7 +511,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
||||||
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.awlanNodeDbTable + "_" + key,
|
OvsdbDao.awlanNodeDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest())),
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))),
|
||||||
new MonitorCallback() {
|
new MonitorCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -615,7 +619,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.wifiRadioStateDbTable + "_" + key,
|
OvsdbDao.wifiRadioStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest())),
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))),
|
||||||
new MonitorCallback() {
|
new MonitorCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -636,7 +640,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.wifiVifStateDbTable + "_" + key,
|
OvsdbDao.wifiVifStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest())),
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
new MonitorCallback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -298,7 +298,9 @@ public class OvsdbDao {
|
|||||||
// when not found - look them up for if_name = br-lan
|
// when not found - look them up for if_name = br-lan
|
||||||
fillInWanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType, defaultLanInterfaceName);
|
fillInWanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType, defaultLanInterfaceName);
|
||||||
|
|
||||||
if (ret.ipV4Address == null) throw new RuntimeException("Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect.");
|
if (ret.ipV4Address == null)
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect.");
|
||||||
}
|
}
|
||||||
fillInLanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType);
|
fillInLanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType);
|
||||||
|
|
||||||
@@ -973,88 +975,6 @@ public class OvsdbDao {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, PortInfo> getProvisionedPorts(OvsdbClient ovsdbClient) {
|
|
||||||
Map<String, PortInfo> ret = new HashMap<>();
|
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
List<String> columns = new ArrayList<>();
|
|
||||||
columns.add("name");
|
|
||||||
columns.add("_uuid");
|
|
||||||
columns.add("interfaces");
|
|
||||||
|
|
||||||
try {
|
|
||||||
LOG.debug("Retrieving Ports:");
|
|
||||||
|
|
||||||
operations.add(new Select(portDbTable, conditions, columns));
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
LOG.debug("Op Result {}", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
|
||||||
|
|
||||||
PortInfo portInfo = new PortInfo();
|
|
||||||
portInfo.name = row.getStringColumn("name");
|
|
||||||
portInfo.uuid = row.getUuidColumn("_uuid");
|
|
||||||
portInfo.interfaceUuids = row.getSetColumn("interfaces");
|
|
||||||
|
|
||||||
ret.put(portInfo.name, portInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug("Retrieved Ports: {}", ret);
|
|
||||||
|
|
||||||
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
|
|
||||||
LOG.error("Error in getProvisionedPorts", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, BridgeInfo> getProvisionedBridges(OvsdbClient ovsdbClient) {
|
|
||||||
Map<String, BridgeInfo> ret = new HashMap<>();
|
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
List<String> columns = new ArrayList<>();
|
|
||||||
columns.add("name");
|
|
||||||
columns.add("_uuid");
|
|
||||||
columns.add("ports");
|
|
||||||
|
|
||||||
try {
|
|
||||||
LOG.debug("Retrieving Bridges:");
|
|
||||||
|
|
||||||
operations.add(new Select(bridgeDbTable, conditions, columns));
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
LOG.debug("Op Result {}", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
|
||||||
|
|
||||||
BridgeInfo bridgeInfo = new BridgeInfo();
|
|
||||||
bridgeInfo.name = row.getStringColumn("name");
|
|
||||||
bridgeInfo.uuid = row.getUuidColumn("_uuid");
|
|
||||||
bridgeInfo.portUuids = row.getSetColumn("ports");
|
|
||||||
|
|
||||||
ret.put(bridgeInfo.name, bridgeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug("Retrieved Bridges: {}", ret);
|
|
||||||
|
|
||||||
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
|
|
||||||
LOG.error("Error in getProvisionedBridges", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) {
|
public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) {
|
||||||
Map<String, CommandConfigInfo> ret = new HashMap<>();
|
Map<String, CommandConfigInfo> ret = new HashMap<>();
|
||||||
|
|
||||||
@@ -1779,62 +1699,106 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void provisionBridgePortInterface(OvsdbClient ovsdbClient) {
|
public void removeAllSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
||||||
|
Map<String, WifiVifConfigInfo> currentWifiVifConfigInfo = getProvisionedWifiVifConfigs(ovsdbClient);
|
||||||
|
Map<String, WifiRadioConfigInfo> currentWifiRadioConfigInfo = getProvisionedWifiRadioConfigs(ovsdbClient);
|
||||||
|
|
||||||
|
List<WifiVifConfigInfo> vifConfigsToDelete = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
for (Entry<String, WifiVifConfigInfo> vifConfigInfo : currentWifiVifConfigInfo.entrySet()) {
|
||||||
|
LOG.debug("Checking {}", vifConfigInfo.getKey());
|
||||||
|
WifiRadioConfigInfo radioConfigInfo = null;
|
||||||
|
if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio0)) {
|
||||||
|
radioConfigInfo = currentWifiRadioConfigInfo.get(radio0);
|
||||||
|
} else if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio1)) {
|
||||||
|
radioConfigInfo = currentWifiRadioConfigInfo.get(radio1);
|
||||||
|
} else if (vifConfigInfo.getValue().ifName.startsWith(defaultRadio2)) {
|
||||||
|
radioConfigInfo = currentWifiRadioConfigInfo.get(radio2);
|
||||||
|
}
|
||||||
|
boolean delete = true;
|
||||||
|
if (radioConfigInfo != null) {
|
||||||
|
final String freqBand = radioConfigInfo.freqBand;
|
||||||
|
if (radioConfigInfo.vifConfigUuids.contains(vifConfigInfo.getValue().uuid)) {
|
||||||
|
if (opensyncAPConfig.getSsidProfile().stream().anyMatch(new Predicate<Profile>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(Profile t) {
|
||||||
|
SsidConfiguration ssidConfig = (SsidConfiguration) t.getDetails();
|
||||||
|
return (ssidConfig.getSsid().equals(vifConfigInfo.getValue().ssid))
|
||||||
|
&& (ssidConfig.getAppliedRadios().contains(OvsdbToWlanCloudTypeMappingUtility
|
||||||
|
.getRadioTypeForOvsdbRadioFreqBand(freqBand)));
|
||||||
|
}
|
||||||
|
|
||||||
|
})) {
|
||||||
|
delete = false;
|
||||||
|
LOG.debug("Do not delete vif {}", vifConfigInfo.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (delete) {
|
||||||
|
vifConfigsToDelete.add(vifConfigInfo.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.debug("The following VIFs should be deleted {}", vifConfigsToDelete);
|
||||||
|
|
||||||
|
|
||||||
|
List<Operation> operations = new ArrayList<>();
|
||||||
|
|
||||||
|
for (WifiVifConfigInfo vifConfigInfo : vifConfigsToDelete) {
|
||||||
|
List<Condition> conditions = new ArrayList<>();
|
||||||
|
conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(vifConfigInfo.uuid)));
|
||||||
|
operations.add(new Delete(wifiVifConfigDbTable, conditions));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
|
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
String patchW2h = "patch-w2h";
|
if (LOG.isDebugEnabled()) {
|
||||||
String patchH2w = "patch-h2w";
|
LOG.debug("Removed existing SSIDs from {}:", wifiVifConfigDbTable);
|
||||||
Map<String, InterfaceInfo> provisionedInterfaces = getProvisionedInterfaces(ovsdbClient);
|
|
||||||
if (provisionedInterfaces.isEmpty()) {
|
for (OperationResult res : result) {
|
||||||
LOG.debug("No Interfaces defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping.");
|
LOG.debug("Op Result {}", res);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
LOG.debug("Existing Interfaces: {}", provisionedInterfaces.keySet());
|
|
||||||
|
|
||||||
Map<String, PortInfo> provisionedPorts = getProvisionedPorts(ovsdbClient);
|
|
||||||
if (provisionedInterfaces.isEmpty()) {
|
|
||||||
LOG.debug("No Ports defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
LOG.debug("Existing Ports: {}", provisionedPorts.keySet());
|
|
||||||
|
|
||||||
Map<String, BridgeInfo> provisionedBridges = getProvisionedBridges(ovsdbClient);
|
operations = new ArrayList<>();
|
||||||
if (provisionedInterfaces.isEmpty()) {
|
// Add vifs to delete
|
||||||
LOG.debug("No Bridges defined in Ovsdb. Cannot perform Bridge/Port/Interface mapping.");
|
for (WifiVifConfigInfo vifConfigInfo : vifConfigsToDelete) {
|
||||||
return;
|
List<Condition> conditions = new ArrayList<>();
|
||||||
|
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(vifConfigInfo.ifName)));
|
||||||
|
operations.add(new Delete(wifiInetConfigDbTable, conditions));
|
||||||
}
|
}
|
||||||
LOG.debug("Existing Bridges: {}", provisionedBridges.keySet());
|
|
||||||
|
|
||||||
Map<String, String> patchH2wOptions = new HashMap<>();
|
fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
patchH2wOptions.put("peer", "patch-w2h");
|
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
Map<String, String> patchW2hOptions = new HashMap<>();
|
if (LOG.isDebugEnabled()) {
|
||||||
patchH2wOptions.put("peer", "patch-h2w");
|
LOG.debug("Removed existing InetConfigs from {}:", wifiVifConfigDbTable);
|
||||||
|
|
||||||
provisionSingleBridgePortInterface(ovsdbClient, patchH2w, bridgeNameVifInterfaces, "patch", patchH2wOptions,
|
for (OperationResult res : result) {
|
||||||
provisionedInterfaces, provisionedPorts, provisionedBridges);
|
LOG.debug("Op Result {}", res);
|
||||||
provisionSingleBridgePortInterface(ovsdbClient, patchW2h, defaultWanInterfaceType, "patch", patchW2hOptions,
|
}
|
||||||
provisionedInterfaces, provisionedPorts, provisionedBridges);
|
}
|
||||||
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio0, bridgeNameVifInterfaces, "vif", null,
|
|
||||||
provisionedInterfaces, provisionedPorts, provisionedBridges);
|
|
||||||
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio1, bridgeNameVifInterfaces, "vif", null,
|
|
||||||
provisionedInterfaces, provisionedPorts, provisionedBridges);
|
|
||||||
provisionSingleBridgePortInterface(ovsdbClient, defaultRadio2, bridgeNameVifInterfaces, "vif", null,
|
|
||||||
provisionedInterfaces, provisionedPorts, provisionedBridges);
|
|
||||||
|
|
||||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
|
||||||
LOG.error("Error in provisionBridgePortInterface", e);
|
|
||||||
|
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
|
LOG.error("Error in removeAllSsids", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAllSsids(OvsdbClient ovsdbClient) {
|
public void removeAllSsids(OvsdbClient ovsdbClient) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
removeAllHotspot20Config(ovsdbClient);
|
removeAllPasspointConfigs(ovsdbClient);
|
||||||
removeAllHotspot20OsuProviders(ovsdbClient);
|
|
||||||
removeAllHotspot20IconConfig(ovsdbClient);
|
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
|
|
||||||
@@ -1893,6 +1857,12 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeAllPasspointConfigs(OvsdbClient ovsdbClient) {
|
||||||
|
removeAllHotspot20Config(ovsdbClient);
|
||||||
|
removeAllHotspot20OsuProviders(ovsdbClient);
|
||||||
|
removeAllHotspot20IconConfig(ovsdbClient);
|
||||||
|
}
|
||||||
|
|
||||||
public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
||||||
|
|
||||||
String country = opensyncAPConfig.getCountryCode(); // should be the
|
String country = opensyncAPConfig.getCountryCode(); // should be the
|
||||||
@@ -2615,7 +2585,7 @@ public class OvsdbDao {
|
|||||||
String ipAssignScheme, List<MacAddress> macBlockList, boolean rateLimitEnable, int ssidDlLimit,
|
String ipAssignScheme, List<MacAddress> macBlockList, boolean rateLimitEnable, int ssidDlLimit,
|
||||||
int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold, int fragThresholdBytes,
|
int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold, int fragThresholdBytes,
|
||||||
int dtimPeriod, Map<String, String> captiveMap, List<String> walledGardenAllowlist,
|
int dtimPeriod, Map<String, String> captiveMap, List<String> walledGardenAllowlist,
|
||||||
Map<Short, Set<String>> bonjourServiceMap) {
|
Map<Short, Set<String>> bonjourServiceMap, boolean isUpdate) {
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
Map<String, Value> updateColumns = new HashMap<>();
|
Map<String, Value> updateColumns = new HashMap<>();
|
||||||
@@ -2718,13 +2688,30 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
updateBlockList(updateColumns, macBlockList);
|
updateBlockList(updateColumns, macBlockList);
|
||||||
Row row = new Row(updateColumns);
|
Row row = new Row(updateColumns);
|
||||||
|
|
||||||
|
|
||||||
|
//////
|
||||||
|
|
||||||
|
if (isUpdate) {
|
||||||
|
List<Condition> conditions = new ArrayList<>();
|
||||||
|
|
||||||
|
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(vifInterfaceName)));
|
||||||
|
operations.add(new Update(wifiVifConfigDbTable, conditions, row));
|
||||||
|
|
||||||
|
} else {
|
||||||
operations.add(new Insert(wifiVifConfigDbTable, row));
|
operations.add(new Insert(wifiVifConfigDbTable, row));
|
||||||
|
}
|
||||||
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
LOG.debug("Provisioned SSID {} on {}", ssid, vifInterfaceName);
|
|
||||||
|
|
||||||
|
if (isUpdate) {
|
||||||
|
for (OperationResult res : result) {
|
||||||
|
LOG.debug("Op Result {}", res);
|
||||||
|
}
|
||||||
|
LOG.info("Updated existing SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
|
||||||
|
} else {
|
||||||
Uuid vifConfigUuid = null;
|
Uuid vifConfigUuid = null;
|
||||||
for (OperationResult res : result) {
|
for (OperationResult res : result) {
|
||||||
LOG.debug("Op Result {}", res);
|
LOG.debug("Op Result {}", res);
|
||||||
@@ -2732,14 +2719,14 @@ public class OvsdbDao {
|
|||||||
vifConfigUuid = ((InsertResult) res).getUuid();
|
vifConfigUuid = ((InsertResult) res).getUuid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vifConfigUuid == null) {
|
if (vifConfigUuid == null) {
|
||||||
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
|
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
|
||||||
}
|
}
|
||||||
updateColumns.clear();
|
updateColumns.clear();
|
||||||
operations.clear();
|
operations.clear();
|
||||||
|
|
||||||
updateVifConfigsSetForRadio(ovsdbClient, ssid, radioFreqBand, operations, updateColumns, vifConfigUuid);
|
updateVifConfigsSetForRadio(ovsdbClient, ssid, radioFreqBand, operations, updateColumns, vifConfigUuid);
|
||||||
|
LOG.info("Provisioned SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient);
|
Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient);
|
||||||
|
|
||||||
@@ -2751,12 +2738,11 @@ public class OvsdbDao {
|
|||||||
(networkForwardMode == NetworkForwardMode.NAT));
|
(networkForwardMode == NetworkForwardMode.NAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Provisioned SSID {} on interface {} / {}", ssid, vifInterfaceName, radioFreqBand);
|
|
||||||
|
|
||||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||||
LOG.error("Error in configureSingleSsid", e);
|
LOG.error("Error in configureSingleSsid", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBlockList(Map<String, Value> updateColumns, List<MacAddress> macBlockList) {
|
private void updateBlockList(Map<String, Value> updateColumns, List<MacAddress> macBlockList) {
|
||||||
@@ -3093,6 +3079,19 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
|
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
boolean isUpdate = false;
|
||||||
|
Map<String, WifiVifConfigInfo> provisionedVifs = getProvisionedWifiVifConfigs(ovsdbClient);
|
||||||
|
for (String key : provisionedVifs.keySet()) {
|
||||||
|
if (key.contains(ifName) && key.contains(ssidConfig.getSsid())) {
|
||||||
|
isUpdate = true;
|
||||||
|
ifName = provisionedVifs.get(key).ifName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isUpdate) {
|
||||||
int numberOfInterfaces = 0;
|
int numberOfInterfaces = 0;
|
||||||
for (String key : getProvisionedWifiVifConfigs(ovsdbClient).keySet()) {
|
for (String key : getProvisionedWifiVifConfigs(ovsdbClient).keySet()) {
|
||||||
if (key.startsWith(ifName)) {
|
if (key.startsWith(ifName)) {
|
||||||
@@ -3100,26 +3099,28 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (numberOfInterfaces >= maxInterfacesPerRadio) {
|
if (numberOfInterfaces >= maxInterfacesPerRadio) {
|
||||||
// this cannot occur, log error, do not try to provision
|
// this cannot occur, log error, do not try to
|
||||||
throw new IllegalStateException(
|
// provision
|
||||||
"Cannot provision more than " + maxInterfacesPerRadio + " interfaces per Wifi Radio");
|
throw new IllegalStateException("Cannot provision more than " + maxInterfacesPerRadio
|
||||||
|
+ " interfaces per Wifi Radio");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numberOfInterfaces > 0) {
|
if (numberOfInterfaces > 0) {
|
||||||
// 1st interface has no number, 2nd has '_1', 3rd has
|
// 1st interface has no number, 2nd has '_1', 3rd
|
||||||
|
// has
|
||||||
// '_2' etc.
|
// '_2' etc.
|
||||||
ifName = ifName + "_" + numberOfInterfaces;
|
ifName = ifName + "_" + numberOfInterfaces;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast, security, freqBand,
|
configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast, security, freqBand,
|
||||||
ssidConfig.getVlanId(), rrmEnabled, enable80211r, mobilityDomain, enable80211v,
|
ssidConfig.getVlanId(), rrmEnabled, enable80211r, mobilityDomain, enable80211v,
|
||||||
enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge,
|
enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge,
|
||||||
ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme, macBlockList,
|
ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme, macBlockList,
|
||||||
rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold,
|
rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold,
|
||||||
fragThresholdBytes, dtimPeriod, captiveMap, walledGardenAllowlist, bonjourServiceMap);
|
fragThresholdBytes, dtimPeriod, captiveMap, walledGardenAllowlist, bonjourServiceMap,
|
||||||
|
isUpdate);
|
||||||
|
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// could not provision this SSID, but still can go on
|
// could not provision this SSID, but still can go on
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
|
|||||||
Mockito.verify(ovsdbSessionMapInterface).getSession("Test_Client_21P10C68818122");
|
Mockito.verify(ovsdbSessionMapInterface).getSession("Test_Client_21P10C68818122");
|
||||||
Mockito.verify(ovsdbSession).getOvsdbClient();
|
Mockito.verify(ovsdbSession).getOvsdbClient();
|
||||||
Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122");
|
Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122");
|
||||||
Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient);
|
Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient, apConfig);
|
||||||
Mockito.verify(ovsdbDao).removeAllStatsConfigs(ovsdbClient);
|
Mockito.verify(ovsdbDao).removeAllStatsConfigs(ovsdbClient);
|
||||||
Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig);
|
Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig);
|
||||||
Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig);
|
Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user