The number of connected AP displayed on Client Devices page and Dashboard page are not in sync.

This commit is contained in:
Mike Hansen
2020-12-12 15:01:00 -05:00
parent 67c0ae9ffc
commit aeb949a884

View File

@@ -303,6 +303,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
EquipmentRoutingRecord equipmentRoutingRecord = gatewayController.registerCustomerEquipment(ce.getName(),
ce.getCustomerId(), ce.getId());
LOG.info("Clear existing status {} for AP {}",
statusServiceInterface.delete(ce.getCustomerId(), ce.getId()), apId);
updateApStatus(ce, connectNodeInfo);
removeNonWifiClients(ce, connectNodeInfo);
@@ -742,7 +745,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} else {
LOG.warn("Cannot find ap {} in inventory", apId);
}
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
if (ce != null) {
LOG.info("AP {} disconnected, delete status records {}", apId,
statusServiceInterface.delete(ce.getCustomerId(), ce.getId()));
}
updateApDisconnectedStatus(apId);
} catch (Exception e) {
LOG.error("Exception when registering ap routing {}", apId, e);
@@ -753,6 +760,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
private void updateApDisconnectedStatus(String apId) {
try {
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
if (ce == null) {
LOG.debug("updateDisconnectedApStatus::Cannot get Equipment for AP {}", apId);
return;
@@ -761,7 +769,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Status statusRecord = statusServiceInterface.getOrNull(ce.getCustomerId(), ce.getId(),
StatusDataType.EQUIPMENT_ADMIN);
if (statusRecord == null) {
LOG.debug("updateApDisconnectedStatus::Cannot get EQUIPMENT_ADMIN status for CustomerId {} or EquipmentId {} for AP {}",
LOG.debug(
"updateApDisconnectedStatus::Cannot get EQUIPMENT_ADMIN status for CustomerId {} or EquipmentId {} for AP {}",
ce.getCustomerId(), ce.getId(), apId);
return;
}
@@ -769,6 +778,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
((EquipmentAdminStatusData) statusRecord.getDetails()).setStatusCode(StatusCode.error);
// Update the equipment admin status
statusRecord = statusServiceInterface.update(statusRecord);
} catch (Exception e) {
LOG.error("Exception in updateApDisconnectedStatus", e);
throw e;
@@ -808,8 +818,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ret.setRfProfile(profileContainer.getChildOfTypeOrNull(equipmentConfig.getProfileId(), ProfileType.rf));
ret.setSsidProfile(
profileContainer.getChildrenOfType(equipmentConfig.getProfileId(), ProfileType.ssid));
ret.setSsidProfile(profileContainer.getChildrenOfType(equipmentConfig.getProfileId(), ProfileType.ssid));
ret.setMetricsProfiles(profileContainer.getChildrenOfType(equipmentConfig.getProfileId(),
ProfileType.service_metrics_collection_config));
@@ -830,8 +839,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
hotspot20ProfileSet
.addAll(profileContainer.getChildrenOfType(ssidProfile.getId(), ProfileType.passpoint));
radiusSet
.addAll(profileContainer.getChildrenOfType(ret.getApProfile().getId(), ProfileType.radius));
radiusSet.addAll(profileContainer.getChildrenOfType(ret.getApProfile().getId(), ProfileType.radius));
if (ssidProfile.getDetails() != null) {
Long captivePortId = ((SsidConfiguration) ssidProfile.getDetails()).getCaptivePortalId();
if (captivePortId != null) {
@@ -849,8 +857,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
for (Profile hotspot20Profile : hotspot20ProfileSet) {
hotspot20OperatorSet.addAll(profileContainer.getChildrenOfType(hotspot20Profile.getId(),
ProfileType.passpoint_operator));
hotspot20VenueSet.addAll(profileContainer.getChildrenOfType(hotspot20Profile.getId(),
ProfileType.passpoint_venue));
hotspot20VenueSet.addAll(
profileContainer.getChildrenOfType(hotspot20Profile.getId(), ProfileType.passpoint_venue));
hotspot20ProviderSet.addAll(profileContainer.getChildrenOfType(hotspot20Profile.getId(),
ProfileType.passpoint_osu_id_provider));
}
@@ -876,7 +884,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
LOG.debug("ApConfig {}", ret);
} catch (Exception e) {
LOG.error("Cannot read config for AP {}", apId, e);
}
@@ -1117,8 +1124,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
protocolStatusData = (EquipmentProtocolStatusData) protocolStatus.getDetails();
if (!protocolStatusData.getReportedCC().equals(CountryCode.getByName((radioState.getCountry())))) {
LOG.debug("Protocol Status reportedCC {} radioStatus.getCountry {} radioStatus CountryCode fromName {}", protocolStatusData.getReportedCC(), radioState.getCountry(), CountryCode.getByName((radioState.getCountry())));
protocolStatusData.setReportedCC(CountryCode.getByName((radioState. getCountry())));
LOG.debug(
"Protocol Status reportedCC {} radioStatus.getCountry {} radioStatus CountryCode fromName {}",
protocolStatusData.getReportedCC(), radioState.getCountry(),
CountryCode.getByName((radioState.getCountry())));
protocolStatusData.setReportedCC(CountryCode.getByName((radioState.getCountry())));
protocolStatus.setDetails(protocolStatusData);
} else {
@@ -1165,8 +1175,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.ACTIVE_BSSIDS);
statusServiceInterface.getForCustomer(customerId, null, ImmutableSet.of(StatusDataType.ACTIVE_BSSIDS), null,
null);
if (activeBssidsStatus == null) {
activeBssidsStatus = new Status();
activeBssidsStatus.setCustomerId(customerId);
@@ -1356,6 +1364,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
public void wifiAssociatedClientsDbTableUpdate(List<OpensyncWifiAssociatedClients> wifiAssociatedClients,
String apId) {
LOG.info("Received wifiAssociatedClientsDbTableUpdate monitor notification for Client(s) {} on AP {}",
wifiAssociatedClients, apId);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {
@@ -1515,12 +1526,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
String reportedSwImageName, String reportedAltSwImageName) {
Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
if (protocolStatus != null) {
EquipmentProtocolStatusData protocolStatusData = ((EquipmentProtocolStatusData) protocolStatus.getDetails());
if (protocolStatusData.getReportedSku() != null && protocolStatusData.getReportedSku().equals(opensyncAPState.getSkuNumber())
&& protocolStatusData.getReportedSwVersion() != null && protocolStatusData.getReportedSwVersion().equals(reportedSwImageName)
&& protocolStatusData.getReportedSwAltVersion() != null && protocolStatusData.getReportedSwAltVersion().equals(reportedAltSwImageName)
&& protocolStatusData.getReportedHwVersion() != null && protocolStatusData.getReportedHwVersion().equals(opensyncAPState.getPlatformVersion())
&& protocolStatusData.getSystemName() != null && protocolStatusData.getSystemName().equals(opensyncAPState.getModel())) {
EquipmentProtocolStatusData protocolStatusData = ((EquipmentProtocolStatusData) protocolStatus
.getDetails());
if (protocolStatusData.getReportedSku() != null
&& protocolStatusData.getReportedSku().equals(opensyncAPState.getSkuNumber())
&& protocolStatusData.getReportedSwVersion() != null
&& protocolStatusData.getReportedSwVersion().equals(reportedSwImageName)
&& protocolStatusData.getReportedSwAltVersion() != null
&& protocolStatusData.getReportedSwAltVersion().equals(reportedAltSwImageName)
&& protocolStatusData.getReportedHwVersion() != null
&& protocolStatusData.getReportedHwVersion().equals(opensyncAPState.getPlatformVersion())
&& protocolStatusData.getSystemName() != null
&& protocolStatusData.getSystemName().equals(opensyncAPState.getModel())) {
// no changes
return null;
}
@@ -1535,20 +1552,24 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} else {
protocolStatusData.setReportedSwAltVersion("Unknown");
}
protocolStatusData
.setReportedHwVersion(opensyncAPState.getPlatformVersion());
protocolStatusData.setReportedHwVersion(opensyncAPState.getPlatformVersion());
protocolStatusData.setSystemName(opensyncAPState.getModel());
}
return protocolStatus;
}
private Status configureFirmwareStatus(int customerId, long equipmentId,EquipmentUpgradeState fwUpgradeState,
private Status configureFirmwareStatus(int customerId, long equipmentId, EquipmentUpgradeState fwUpgradeState,
FailureReason fwUpgradeFailureReason, String reportedFwImageName, String reportedAltFwImageName) {
Status firmwareStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.FIRMWARE);
if (firmwareStatus != null) {
EquipmentUpgradeStatusData upgradeStatusData = (EquipmentUpgradeStatusData)firmwareStatus.getDetails();
if (upgradeStatusData.getActiveSwVersion() != null && upgradeStatusData.getActiveSwVersion().equals(reportedFwImageName) && upgradeStatusData.getAlternateSwVersion() != null &&upgradeStatusData.getAlternateSwVersion().equals(reportedAltFwImageName) && upgradeStatusData.getUpgradeState() != null && upgradeStatusData.getUpgradeState().equals(fwUpgradeState)) {
EquipmentUpgradeStatusData upgradeStatusData = (EquipmentUpgradeStatusData) firmwareStatus.getDetails();
if (upgradeStatusData.getActiveSwVersion() != null
&& upgradeStatusData.getActiveSwVersion().equals(reportedFwImageName)
&& upgradeStatusData.getAlternateSwVersion() != null
&& upgradeStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)
&& upgradeStatusData.getUpgradeState() != null
&& upgradeStatusData.getUpgradeState().equals(fwUpgradeState)) {
return null; // no changes
}
if (reportedFwImageName != null) {
@@ -1560,11 +1581,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (reportedAltFwImageName != null) {
upgradeStatusData.setAlternateSwVersion(reportedAltFwImageName);
} else {
((EquipmentUpgradeStatusData) firmwareStatus.getDetails())
.setAlternateSwVersion("Unknown");
((EquipmentUpgradeStatusData) firmwareStatus.getDetails()).setAlternateSwVersion("Unknown");
}
if (fwUpgradeState == null) fwUpgradeState = EquipmentUpgradeState.undefined;
if (fwUpgradeState == null)
fwUpgradeState = EquipmentUpgradeState.undefined;
if (fwUpgradeState.equals(EquipmentUpgradeState.up_to_date)) {
LOG.info("Firmware load is up to date.");
@@ -1600,8 +1621,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
((EquipmentUpgradeStatusData) firmwareStatus.getDetails())
.setUpgradeState(EquipmentUpgradeState.undefined);
((EquipmentUpgradeStatusData) firmwareStatus.getDetails())
.setUpgradeStartTime(null);
((EquipmentUpgradeStatusData) firmwareStatus.getDetails()).setUpgradeStartTime(null);
}
}
return firmwareStatus;
@@ -1661,7 +1681,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (bssidList != null) bssidList.removeAll(toBeDeleted);
if (bssidList != null)
bssidList.removeAll(toBeDeleted);
statusDetails.setActiveBSSIDs(bssidList);
@@ -1676,6 +1697,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
@Override
public void wifiAssociatedClientsDbTableDelete(String deletedClientMac, String apId) {
LOG.info("Received wifiAssociatedClientsDbTableDelete monitor notification for MAC {} on AP {}",
deletedClientMac, apId);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {
@@ -1698,7 +1721,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
new MacAddress(deletedClientMac));
if (client != null) {
if (clientSession != null && clientSession.getDetails() != null && clientSession.getDetails().getAssociationState() != null) {
if (clientSession != null && clientSession.getDetails() != null
&& clientSession.getDetails().getAssociationState() != null) {
if (!clientSession.getDetails().getAssociationState().equals(AssociationState.Disconnected)) {
clientSession.getDetails().setAssociationState(AssociationState.Disconnected);
clientSession = clientServiceInterface.updateSession(clientSession);
@@ -2083,5 +2107,4 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// TODO: will handle changes from Command_State table
}
}