From 14cc34ef7552b6b5541eb07edd0789dfe0639851 Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Sun, 13 Dec 2020 15:42:04 -0500 Subject: [PATCH] WIFI-1195: JsonSerializedException for MacAddress with Client Interface --- .../OpensyncExternalIntegrationCloud.java | 117 +++++++++++++++--- ...ternalIntegrationMqttMessageProcessor.java | 86 ++++++------- .../OpensyncExternalIntegrationCloudTest.java | 8 +- ...alIntegrationMqttMessageProcessorTest.java | 8 +- .../OpensyncExternalIntegrationInterface.java | 2 + .../OpensyncExternalIntegrationSimple.java | 6 + .../opensync/ovsdb/TipWlanOvsdbClient.java | 6 + 7 files changed, 165 insertions(+), 68 deletions(-) diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java index 976f1cb..8ef0483 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.telecominfraproject.wlan.client.ClientServiceInterface; import com.telecominfraproject.wlan.client.info.models.ClientInfoDetails; +import com.telecominfraproject.wlan.client.models.Client; import com.telecominfraproject.wlan.client.models.ClientType; import com.telecominfraproject.wlan.client.session.models.AssociationState; import com.telecominfraproject.wlan.client.session.models.ClientDhcpDetails; @@ -92,6 +93,9 @@ import com.telecominfraproject.wlan.status.equipment.models.VLANStatusData; import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSID; import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSIDs; import com.telecominfraproject.wlan.status.equipment.report.models.ClientConnectionDetails; +import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentScanDetails; +import com.telecominfraproject.wlan.status.equipment.report.models.OperatingSystemPerformance; +import com.telecominfraproject.wlan.status.equipment.report.models.RadioUtilizationReport; import com.telecominfraproject.wlan.status.models.Status; import com.telecominfraproject.wlan.status.models.StatusCode; import com.telecominfraproject.wlan.status.models.StatusDataType; @@ -186,7 +190,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra ce.setEquipmentType(EquipmentType.AP); ce.setInventoryId(apId); try { - ce.setBaseMacAddress(new MacAddress(connectNodeInfo.macAddress)); + ce.setBaseMacAddress(MacAddress.valueOf(connectNodeInfo.macAddress)); } catch (RuntimeException e) { LOG.warn("Auto-provisioning: cannot parse equipment mac address {}", connectNodeInfo.macAddress); } @@ -280,7 +284,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra MacAddress reportedMacAddress = null; try { - reportedMacAddress = new MacAddress(connectNodeInfo.macAddress); + reportedMacAddress = MacAddress.valueOf(connectNodeInfo.macAddress); } catch (RuntimeException e) { LOG.warn("AP connect: cannot parse equipment mac address {}", connectNodeInfo.macAddress); } @@ -569,7 +573,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra // need to make sure that this AP didn't accidentally get registered as // a client previously via a partial DHCP lease event LOG.info("Checking for non-wifi client types for Equipment {}", ce); - com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(ce.getCustomerId(), + Client client = clientServiceInterface.getOrNull(ce.getCustomerId(), ce.getBaseMacAddress()); if (client != null) { @@ -874,7 +878,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra ret.setCaptiveProfiles(profileServiceInterface.get(captiveProfileIds)); ret.setBonjourGatewayProfiles(profileServiceInterface.get(bonjourGatewayProfileIds)); - List blockedClients = clientServiceInterface + List blockedClients = clientServiceInterface .getBlockedClients(customerId); List blockList = Lists.newArrayList(); if ((blockedClients != null) && !blockedClients.isEmpty()) { @@ -1395,15 +1399,21 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } for (OpensyncWifiAssociatedClients opensyncWifiAssociatedClients : wifiAssociatedClients) { - com.telecominfraproject.wlan.client.models.Client clientInstance = clientServiceInterface - .getOrNull(customerId, new MacAddress(opensyncWifiAssociatedClients.getMac())); + + LOG.info("opensyncWifiAssociatedClients {}", opensyncWifiAssociatedClients.toPrettyString()); + + String mMac = opensyncWifiAssociatedClients.mac; + MacAddress macAddress = MacAddress.valueOf(mMac); + + Client clientInstance = clientServiceInterface + .getOrNull(customerId, macAddress); boolean isReassociation = true; if (clientInstance == null) { - clientInstance = new com.telecominfraproject.wlan.client.models.Client(); + clientInstance = new Client(); clientInstance.setCustomerId(customerId); - clientInstance.setMacAddress(new MacAddress(opensyncWifiAssociatedClients.getMac())); + clientInstance.setMacAddress(MacAddress.valueOf(mMac)); clientInstance.setDetails(new ClientInfoDetails()); clientInstance = clientServiceInterface.create(clientInstance); @@ -1715,10 +1725,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return; } - com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(deletedClientMac)); + Client client = clientServiceInterface.getOrNull(customerId, + MacAddress.valueOf(deletedClientMac)); ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(deletedClientMac)); + MacAddress.valueOf(deletedClientMac)); if (client != null) { if (clientSession != null && clientSession.getDetails() != null @@ -1734,9 +1744,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra if (clientSession != null) { clientSession = clientServiceInterface.deleteSession(customerId, equipmentId, - new MacAddress(deletedClientMac)); + MacAddress.valueOf(deletedClientMac)); - LOG.info("No client {} found, delete session {}", new MacAddress(deletedClientMac), clientSession); + LOG.info("No client {} found, delete session {}", MacAddress.valueOf(deletedClientMac), clientSession); } } @@ -1783,9 +1793,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra continue; } - MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr")); + MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr")); - com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, + Client client = clientServiceInterface.getOrNull(customerId, clientMacAddress); if (client == null) { @@ -1875,9 +1885,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } - MacAddress clientMacAddress = new MacAddress(dhcpLeasedIps.get("hwaddr")); + MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr")); - com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, + Client client = clientServiceInterface.getOrNull(customerId, clientMacAddress); if (client == null) { LOG.info("Cannot find client instance for {}", clientMacAddress); @@ -2107,4 +2117,77 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra // TODO: will handle changes from Command_State table } + + @Override + public void clearEquipmentStatus(String apId) { + + OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); + + if (ovsdbSession == null) { + LOG.debug("clearEquipmentStatus::Cannot get Session for AP {}", apId); + return; + } + + int customerId = ovsdbSession.getCustomerId(); + long equipmentId = ovsdbSession.getEquipmentId(); + + if ((customerId < 0) || (equipmentId < 0)) { + LOG.debug("clearEquipmentStatus::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", + customerId, equipmentId, apId); + return; + } + + Equipment ce = equipmentServiceInterface.getOrNull(equipmentId); + + if (ce == null) { + LOG.debug("clearEquipmentStatus Cannot get customer Equipment for {}", apId); + return; + } + + List statusesToClear = new ArrayList<>(); + + Status activeBssids = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.ACTIVE_BSSIDS); + if (activeBssids != null) { + activeBssids.setDetails(new ActiveBSSIDs()); + statusesToClear.add(activeBssids); + } + Status clientDetails = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.CLIENT_DETAILS); + if (clientDetails != null) { + clientDetails.setDetails(new ClientConnectionDetails()); + statusesToClear.add(clientDetails); + } + Status radioUtilization = statusServiceInterface.getOrNull(customerId, equipmentId, + StatusDataType.RADIO_UTILIZATION); + if (radioUtilization != null) { + radioUtilization.setDetails(new RadioUtilizationReport()); + statusesToClear.add(radioUtilization); + } + Status neighbourScanDetails = statusServiceInterface.getOrNull(customerId, equipmentId, + StatusDataType.NEIGHBOUR_SCAN); + if (neighbourScanDetails != null) { + neighbourScanDetails.setDetails(new EquipmentScanDetails()); + statusesToClear.add(neighbourScanDetails); + } + Status operatingSystemPerformance = statusServiceInterface.getOrNull(customerId, equipmentId, + StatusDataType.OS_PERFORMANCE); + if (operatingSystemPerformance != null) { + operatingSystemPerformance.setDetails(new OperatingSystemPerformance()); + statusesToClear.add(operatingSystemPerformance); + } + + List clearedStatus = statusServiceInterface.update(statusesToClear); + + + clearedStatus.stream().forEach(s -> { + LOG.info("Cleared Status {}", s.toPrettyString()); + }); + + + List customerDashboardStatus = statusServiceInterface.getForEquipment(customerId, Set.of(equipmentId), Set.of(StatusDataType.CUSTOMER_DASHBOARD)); + for (Status status : customerDashboardStatus) { + LOG.info("Updated status {}", statusServiceInterface.update(status) ); + } + + + } } diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java index dac7a92..bf79034 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessor.java @@ -396,12 +396,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientConnectEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientConnectEvent.getStaMac())); + MacAddress.valueOf(clientConnectEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientConnectEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -410,7 +410,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientConnectEvent.getStaMac())); + MacAddress.valueOf(clientConnectEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -419,7 +419,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientConnectEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientConnectEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); clientSessionDetails.setSessionId(apEventClientSession.getSessionId()); @@ -530,12 +530,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientDisconnectEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientDisconnectEvent.getStaMac())); + MacAddress.valueOf(clientDisconnectEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientDisconnectEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientDisconnectEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -544,7 +544,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientDisconnectEvent.getStaMac())); + MacAddress.valueOf(clientDisconnectEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -553,7 +553,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientDisconnectEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientDisconnectEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -612,12 +612,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientAuthEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientAuthEvent.getStaMac())); + MacAddress.valueOf(clientAuthEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientAuthEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientAuthEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -626,7 +626,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientAuthEvent.getStaMac())); + MacAddress.valueOf(clientAuthEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -635,7 +635,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientAuthEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientAuthEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -671,12 +671,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { for (ClientAssocEvent clientAssocEvent : apEventClientSession.getClientAssocEventList()) { if (clientAssocEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientAssocEvent.getStaMac())); + MacAddress.valueOf(clientAssocEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientAssocEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientAssocEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -685,7 +685,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientAssocEvent.getStaMac())); + MacAddress.valueOf(clientAssocEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -693,7 +693,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientAssocEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientAssocEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); if (clientAssocEvent.hasUsing11K()) { @@ -745,12 +745,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientFailureEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientFailureEvent.getStaMac())); + MacAddress.valueOf(clientFailureEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientFailureEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientFailureEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -759,7 +759,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientFailureEvent.getStaMac())); + MacAddress.valueOf(clientFailureEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -768,7 +768,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientFailureEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientFailureEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -807,12 +807,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientFirstDataEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientFirstDataEvent.getStaMac())); + MacAddress.valueOf(clientFirstDataEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientFirstDataEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientFirstDataEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -821,7 +821,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientFirstDataEvent.getStaMac())); + MacAddress.valueOf(clientFirstDataEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -830,7 +830,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientFirstDataEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientFirstDataEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -866,12 +866,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientIdEvent.hasCltMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientIdEvent.getCltMac())); + MacAddress.valueOf(clientIdEvent.getCltMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientIdEvent.getCltMac())); + client.setMacAddress(MacAddress.valueOf(clientIdEvent.getCltMac())); client.setDetails(new ClientInfoDetails()); @@ -880,7 +880,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientIdEvent.getCltMac())); + MacAddress.valueOf(clientIdEvent.getCltMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -889,7 +889,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientIdEvent.getCltMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientIdEvent.getCltMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -915,12 +915,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientIpEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientIpEvent.getStaMac())); + MacAddress.valueOf(clientIpEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientIpEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientIpEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -929,7 +929,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientIpEvent.getStaMac())); + MacAddress.valueOf(clientIpEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -938,7 +938,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientIpEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientIpEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -972,12 +972,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { if (clientTimeoutEvent.hasStaMac()) { com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, - new MacAddress(clientTimeoutEvent.getStaMac())); + MacAddress.valueOf(clientTimeoutEvent.getStaMac())); if (client == null) { client = new com.telecominfraproject.wlan.client.models.Client(); client.setCustomerId(customerId); - client.setMacAddress(new MacAddress(clientTimeoutEvent.getStaMac())); + client.setMacAddress(MacAddress.valueOf(clientTimeoutEvent.getStaMac())); client.setDetails(new ClientInfoDetails()); @@ -986,7 +986,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(clientTimeoutEvent.getStaMac())); + MacAddress.valueOf(clientTimeoutEvent.getStaMac())); if (clientSession == null) { clientSession = new ClientSession(); @@ -995,7 +995,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { clientSession.setCustomerId(customerId); clientSession.setEquipmentId(equipmentId); clientSession.setLocationId(locationId); - clientSession.setMacAddress(new MacAddress(clientTimeoutEvent.getStaMac())); + clientSession.setMacAddress(MacAddress.valueOf(clientTimeoutEvent.getStaMac())); ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); @@ -1621,7 +1621,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { List clientMacList = new ArrayList<>(); clientMacs.forEach(macStr -> { try { - clientMacList.add(new MacAddress(macStr)); + clientMacList.add(MacAddress.valueOf(macStr)); } catch (RuntimeException e) { LOG.warn("Cannot parse mac address from MQTT ClientReport {} ", macStr); } @@ -1926,12 +1926,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { LOG.debug("Processing ClientReport from AP {}", cl.getMacAddress()); - ServiceMetric smr = new ServiceMetric(customerId, equipmentId, new MacAddress(cl.getMacAddress())); + ServiceMetric smr = new ServiceMetric(customerId, equipmentId, MacAddress.valueOf(cl.getMacAddress())); smr.setLocationId(locationId); metricRecordList.add(smr); smr.setCreatedTimestamp(clReport.getTimestampMs()); - smr.setClientMac(new MacAddress(cl.getMacAddress()).getAddressAsLong()); + smr.setClientMac(MacAddress.valueOf(cl.getMacAddress()).getAddressAsLong()); // clReport.getChannel(); ClientMetrics cMetrics = new ClientMetrics(); @@ -2058,7 +2058,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { } nr.setChannel(nBss.getChannel()); - nr.setMacAddress(new MacAddress(nBss.getBssid())); + nr.setMacAddress(MacAddress.valueOf(nBss.getBssid())); nr.setNetworkType(NetworkType.AP); nr.setPacketType(NeighborScanPacketType.BEACON); nr.setPrivacy(((nBss.getSsid() == null) || nBss.getSsid().isEmpty()) ? true : false); @@ -2085,7 +2085,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { equipmentId, locationId, client.getMacAddress()); com.telecominfraproject.wlan.client.models.Client clientInstance = clientServiceInterface - .getOrNull(customerId, new MacAddress(client.getMacAddress())); + .getOrNull(customerId, MacAddress.valueOf(client.getMacAddress())); boolean isReassociation = true; if (clientInstance == null) { @@ -2293,7 +2293,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails(); for (ActiveBSSID activeBSSID : ((ActiveBSSIDs) activeBssidsStatus.getDetails()).getActiveBSSIDs()) { if (activeBSSID.getRadioType().equals(radioType)) { - ssidStatistics.setBssid(new MacAddress(activeBSSID.getBssid())); + ssidStatistics.setBssid(MacAddress.valueOf(activeBSSID.getBssid())); // ssid value, in case not in stats, else will take // stats value after ssid = activeBSSID.getSsid(); @@ -2346,7 +2346,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor { // disconnect occured during this window if (client.hasMacAddress()) { ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, - new MacAddress(client.getMacAddress())); + MacAddress.valueOf(client.getMacAddress())); if (session != null) { if ((session.getDetails().getAssociationState() != null) && !session.getDetails() diff --git a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java index 1472929..b1a53de 100644 --- a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java +++ b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java @@ -493,10 +493,10 @@ public class OpensyncExternalIntegrationCloudTest { Mockito.when(statusServiceInterface.update(ArgumentMatchers.any(Status.class))).thenReturn(bssidStatus); com.telecominfraproject.wlan.client.models.Client clientInstance = new com.telecominfraproject.wlan.client.models.Client(); - clientInstance.setMacAddress(new MacAddress("7C:AB:60:E6:EA:4D")); + clientInstance.setMacAddress(MacAddress.valueOf("7C:AB:60:E6:EA:4D")); clientInstance.setDetails(new ClientInfoDetails()); com.telecominfraproject.wlan.client.models.Client clientInstance2 = new com.telecominfraproject.wlan.client.models.Client(); - clientInstance2.setMacAddress(new MacAddress("C0:9A:D0:76:A9:69")); + clientInstance2.setMacAddress(MacAddress.valueOf("C0:9A:D0:76:A9:69")); clientInstance2.setDetails(new ClientInfoDetails()); Mockito.when( clientServiceInterface.getOrNull(ArgumentMatchers.anyInt(), ArgumentMatchers.any(MacAddress.class))) @@ -506,10 +506,10 @@ public class OpensyncExternalIntegrationCloudTest { .thenReturn(clientInstance).thenReturn(clientInstance2); ClientSession clientSession = new ClientSession(); - clientSession.setMacAddress(new MacAddress("7C:AB:60:E6:EA:4D")); + clientSession.setMacAddress(MacAddress.valueOf("7C:AB:60:E6:EA:4D")); clientSession.setDetails(new ClientSessionDetails()); ClientSession clientSession2 = new ClientSession(); - clientSession2.setMacAddress(new MacAddress("C0:9A:D0:76:A9:69")); + clientSession2.setMacAddress(MacAddress.valueOf("C0:9A:D0:76:A9:69")); clientSession2.setDetails(new ClientSessionDetails()); Mockito.when(clientServiceInterface.getSessionOrNull(ArgumentMatchers.anyInt(), ArgumentMatchers.anyLong(), ArgumentMatchers.any(MacAddress.class))).thenReturn(clientSession).thenReturn(clientSession2); diff --git a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java index 1232e92..064ec90 100644 --- a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java +++ b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationMqttMessageProcessorTest.java @@ -210,10 +210,10 @@ public class OpensyncExternalIntegrationMqttMessageProcessorTest { Mockito.when(statusServiceInterface.update(ArgumentMatchers.any(Status.class))).thenReturn(bssidStatus); com.telecominfraproject.wlan.client.models.Client clientInstance = new com.telecominfraproject.wlan.client.models.Client(); - clientInstance.setMacAddress(new MacAddress("7C:AB:60:E6:EA:4D")); + clientInstance.setMacAddress(MacAddress.valueOf("7C:AB:60:E6:EA:4D")); clientInstance.setDetails(new ClientInfoDetails()); com.telecominfraproject.wlan.client.models.Client clientInstance2 = new com.telecominfraproject.wlan.client.models.Client(); - clientInstance2.setMacAddress(new MacAddress("C0:9A:D0:76:A9:69")); + clientInstance2.setMacAddress(MacAddress.valueOf("C0:9A:D0:76:A9:69")); clientInstance2.setDetails(new ClientInfoDetails()); Mockito.when( clientServiceInterface.getOrNull(ArgumentMatchers.anyInt(), ArgumentMatchers.any(MacAddress.class))) @@ -223,10 +223,10 @@ public class OpensyncExternalIntegrationMqttMessageProcessorTest { .thenReturn(clientInstance).thenReturn(clientInstance2); ClientSession clientSession = new ClientSession(); - clientSession.setMacAddress(new MacAddress("7C:AB:60:E6:EA:4D")); + clientSession.setMacAddress(MacAddress.valueOf("7C:AB:60:E6:EA:4D")); clientSession.setDetails(new ClientSessionDetails()); ClientSession clientSession2 = new ClientSession(); - clientSession2.setMacAddress(new MacAddress("C0:9A:D0:76:A9:69")); + clientSession2.setMacAddress(MacAddress.valueOf("C0:9A:D0:76:A9:69")); clientSession2.setDetails(new ClientSessionDetails()); Mockito.when(clientServiceInterface.getSessionOrNull(ArgumentMatchers.anyInt(), ArgumentMatchers.anyLong(), ArgumentMatchers.any(MacAddress.class))).thenReturn(clientSession).thenReturn(clientSession2); diff --git a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationInterface.java b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationInterface.java index 0e6161f..d76b3c5 100644 --- a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationInterface.java +++ b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationInterface.java @@ -51,4 +51,6 @@ public interface OpensyncExternalIntegrationInterface { void dhcpLeasedIpDbTableUpdate(List> dhcpAttributes, String apId, RowUpdateOperation rowUpdateOperation); void commandStateDbTableUpdate(List> commandStateAttributes, String apId, RowUpdateOperation rowUpdateOperation); + + void clearEquipmentStatus(String apId); } diff --git a/opensync-ext-static/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationSimple.java b/opensync-ext-static/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationSimple.java index 4e56ddc..62513ed 100644 --- a/opensync-ext-static/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationSimple.java +++ b/opensync-ext-static/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationSimple.java @@ -275,4 +275,10 @@ public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegr } + @Override + public void clearEquipmentStatus(String apId) { + LOG.info("Received clearEquipmentStatus for ap {}",apId); + + } + } diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java index 94d9c52..5e7615c 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java @@ -199,6 +199,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { ovsdbDao.removeWifiRrm(ovsdbClient); ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always + extIntegrationInterface.clearEquipmentStatus(apId); + OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); if (opensyncAPConfig != null) { @@ -273,6 +275,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { ovsdbDao.removeWifiRrm(ovsdbClient); ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always + + extIntegrationInterface.clearEquipmentStatus(apId); + + ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig); ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);