REST API :Get all Status objects for a given customer equipment doesn't return any response

This commit is contained in:
Mike Hansen
2020-12-14 11:29:04 -05:00
parent aead466770
commit 40ac428bb5
2 changed files with 90 additions and 104 deletions

View File

@@ -309,7 +309,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
LOG.info("Clear existing status {} for AP {}", LOG.info("Clear existing status {} for AP {}",
statusServiceInterface.delete(ce.getCustomerId(), ce.getId()), apId); statusServiceInterface.delete(ce.getCustomerId(), ce.getId()), apId);
updateApStatus(ce, connectNodeInfo); updateApStatus(ce, connectNodeInfo);
removeNonWifiClients(ce, connectNodeInfo); removeNonWifiClients(ce, connectNodeInfo);
@@ -573,8 +573,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// need to make sure that this AP didn't accidentally get registered as // need to make sure that this AP didn't accidentally get registered as
// a client previously via a partial DHCP lease event // a client previously via a partial DHCP lease event
LOG.info("Checking for non-wifi client types for Equipment {}", ce); LOG.info("Checking for non-wifi client types for Equipment {}", ce);
Client client = clientServiceInterface.getOrNull(ce.getCustomerId(), Client client = clientServiceInterface.getOrNull(ce.getCustomerId(), ce.getBaseMacAddress());
ce.getBaseMacAddress());
if (client != null) { if (client != null) {
ClientSession clientSession = clientServiceInterface.getSessionOrNull(ce.getCustomerId(), ce.getId(), ClientSession clientSession = clientServiceInterface.getSessionOrNull(ce.getCustomerId(), ce.getId(),
@@ -753,35 +752,33 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (ce != null) { if (ce != null) {
LOG.info("AP {} disconnected, delete status records {}", apId, LOG.info("AP {} disconnected, delete status records {}", apId,
statusServiceInterface.delete(ce.getCustomerId(), ce.getId())); statusServiceInterface.delete(ce.getCustomerId(), ce.getId()));
updateApDisconnectedStatus(apId,ce);
} else {
LOG.error("updateDisconnectedApStatus::Cannot get Equipment for AP {} to update the EquipmentAdminStatus", apId);
} }
updateApDisconnectedStatus(apId);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Exception when registering ap routing {}", apId, e); LOG.error("Exception when registering ap routing {}", apId, e);
} }
} }
private void updateApDisconnectedStatus(String apId) { private void updateApDisconnectedStatus(String apId, Equipment ce) {
LOG.info("updateApDisconnectedStatus disconnected AP {}",apId);
try { try {
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); Status statusRecord = new Status();
statusRecord.setCustomerId(ce.getCustomerId());
statusRecord.setEquipmentId(ce.getId());
statusRecord.setStatusDataType(StatusDataType.EQUIPMENT_ADMIN);
if (ce == null) { EquipmentAdminStatusData statusData = new EquipmentAdminStatusData();
LOG.debug("updateDisconnectedApStatus::Cannot get Equipment for AP {}", apId); statusData.setStatusMessage("AP Disconnected");
return; statusData.setStatusCode(StatusCode.disabled);
}
Status statusRecord = statusServiceInterface.getOrNull(ce.getCustomerId(), ce.getId(), statusRecord.setDetails(statusData);
StatusDataType.EQUIPMENT_ADMIN);
if (statusRecord == null) {
LOG.debug(
"updateApDisconnectedStatus::Cannot get EQUIPMENT_ADMIN status for CustomerId {} or EquipmentId {} for AP {}",
ce.getCustomerId(), ce.getId(), apId);
return;
}
((EquipmentAdminStatusData) statusRecord.getDetails()).setStatusCode(StatusCode.error); LOG.info("Updated EquipmentAdminStatus {} for disconnected AP {}",
// Update the equipment admin status statusServiceInterface.update(statusRecord), apId);
statusRecord = statusServiceInterface.update(statusRecord);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Exception in updateApDisconnectedStatus", e); LOG.error("Exception in updateApDisconnectedStatus", e);
@@ -878,8 +875,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ret.setCaptiveProfiles(profileServiceInterface.get(captiveProfileIds)); ret.setCaptiveProfiles(profileServiceInterface.get(captiveProfileIds));
ret.setBonjourGatewayProfiles(profileServiceInterface.get(bonjourGatewayProfileIds)); ret.setBonjourGatewayProfiles(profileServiceInterface.get(bonjourGatewayProfileIds));
List<Client> blockedClients = clientServiceInterface List<Client> blockedClients = clientServiceInterface.getBlockedClients(customerId);
.getBlockedClients(customerId);
List<MacAddress> blockList = Lists.newArrayList(); List<MacAddress> blockList = Lists.newArrayList();
if ((blockedClients != null) && !blockedClients.isEmpty()) { if ((blockedClients != null) && !blockedClients.isEmpty()) {
blockedClients.forEach(client -> blockList.add(client.getMacAddress())); blockedClients.forEach(client -> blockList.add(client.getMacAddress()));
@@ -1399,14 +1395,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
for (OpensyncWifiAssociatedClients opensyncWifiAssociatedClients : wifiAssociatedClients) { for (OpensyncWifiAssociatedClients opensyncWifiAssociatedClients : wifiAssociatedClients) {
LOG.info("opensyncWifiAssociatedClients {}", opensyncWifiAssociatedClients.toPrettyString()); LOG.info("opensyncWifiAssociatedClients {}", opensyncWifiAssociatedClients.toPrettyString());
String mMac = opensyncWifiAssociatedClients.mac; String mMac = opensyncWifiAssociatedClients.mac;
MacAddress macAddress = MacAddress.valueOf(mMac); MacAddress macAddress = MacAddress.valueOf(mMac);
Client clientInstance = clientServiceInterface Client clientInstance = clientServiceInterface.getOrNull(customerId, macAddress);
.getOrNull(customerId, macAddress);
boolean isReassociation = true; boolean isReassociation = true;
if (clientInstance == null) { if (clientInstance == null) {
@@ -1725,8 +1720,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Client client = clientServiceInterface.getOrNull(customerId, Client client = clientServiceInterface.getOrNull(customerId, MacAddress.valueOf(deletedClientMac));
MacAddress.valueOf(deletedClientMac));
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId,
MacAddress.valueOf(deletedClientMac)); MacAddress.valueOf(deletedClientMac));
@@ -1795,8 +1789,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
} }
MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr")); MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr"));
Client client = clientServiceInterface.getOrNull(customerId, Client client = clientServiceInterface.getOrNull(customerId, clientMacAddress);
clientMacAddress);
if (client == null) { if (client == null) {
LOG.info("Cannot find client instance for {}", clientMacAddress); LOG.info("Cannot find client instance for {}", clientMacAddress);
@@ -1887,8 +1880,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr")); MacAddress clientMacAddress = MacAddress.valueOf(dhcpLeasedIps.get("hwaddr"));
Client client = clientServiceInterface.getOrNull(customerId, Client client = clientServiceInterface.getOrNull(customerId, clientMacAddress);
clientMacAddress);
if (client == null) { if (client == null) {
LOG.info("Cannot find client instance for {}", clientMacAddress); LOG.info("Cannot find client instance for {}", clientMacAddress);
continue; continue;
@@ -1971,32 +1963,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
protected ClientSession updateClientSession(int customerId, long equipmentId, long locationId, protected ClientSession updateClientSession(int customerId, long equipmentId, long locationId,
Map<String, String> dhcpLeasedIps, MacAddress clientMacAddress) { Map<String, String> dhcpLeasedIps, MacAddress clientMacAddress) {
ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress); ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress);
//         "hwaddr": --
//         "inet_addr": --
//         "hostname": --
//         "fingerprint": --
//         "vendor_class": --
//         "lease_time": --
//         "subnet_mask": --
//         "gateway": --
//         "dhcp_server": --
//         "primary_dns": --
//         "secondary_dns": --
//         "db_status":
//         "device_name":
//         "device_type":
//         "manuf_id":
if (session == null) { if (session == null) {
LOG.info("Cannot get session for client {} for customerId {} equipmentId {} locationId {}",
clientMacAddress, customerId, equipmentId, locationId);
return null; return null;
} }
session.setCustomerId(customerId);
session.setEquipmentId(equipmentId);
session.setLocationId(locationId);
session.setMacAddress(clientMacAddress);
session.setDetails(new ClientSessionDetails());
ClientSessionDetails clientSessionDetails = new ClientSessionDetails(); ClientSessionDetails clientSessionDetails = new ClientSessionDetails();
@@ -2117,7 +2092,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// TODO: will handle changes from Command_State table // TODO: will handle changes from Command_State table
} }
@Override @Override
public void clearEquipmentStatus(String apId) { public void clearEquipmentStatus(String apId) {
@@ -2132,8 +2107,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
long equipmentId = ovsdbSession.getEquipmentId(); long equipmentId = ovsdbSession.getEquipmentId();
if ((customerId < 0) || (equipmentId < 0)) { if ((customerId < 0) || (equipmentId < 0)) {
LOG.debug("clearEquipmentStatus::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", LOG.debug("clearEquipmentStatus::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId,
customerId, equipmentId, apId); equipmentId, apId);
return; return;
} }
@@ -2144,50 +2119,61 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
List<Status> statusesToClear = new ArrayList<>(); List<Status> statusList = new ArrayList<>();
Status activeBssids = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.ACTIVE_BSSIDS); Status status = new Status();
if (activeBssids != null) { status.setCustomerId(customerId);
activeBssids.setDetails(new ActiveBSSIDs()); status.setEquipmentId(equipmentId);
statusesToClear.add(activeBssids); status.setStatusDataType(StatusDataType.ACTIVE_BSSIDS);
} status.setDetails(new 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<Status> clearedStatus = statusServiceInterface.update(statusesToClear); statusList.add(status);
status = new Status();
status.setCustomerId(customerId);
status.setEquipmentId(equipmentId);
status.setStatusDataType(StatusDataType.CLIENT_DETAILS);
status.setDetails(new ClientConnectionDetails());
statusList.add(status);
status = new Status();
status.setCustomerId(customerId);
status.setEquipmentId(equipmentId);
status.setStatusDataType(StatusDataType.RADIO_UTILIZATION);
status.setDetails(new RadioUtilizationReport());
statusList.add(status);
status = new Status();
status.setCustomerId(customerId);
status.setEquipmentId(equipmentId);
status.setStatusDataType(StatusDataType.NEIGHBOUR_SCAN);
status.setDetails(new EquipmentScanDetails());
statusList.add(status);
status = new Status();
status.setCustomerId(customerId);
status.setEquipmentId(equipmentId);
status.setStatusDataType(StatusDataType.OS_PERFORMANCE);
status.setDetails(new OperatingSystemPerformance());
statusList.add(status);
LOG.info("MJH statusList to clear {}", statusList);
List<Status> clearedStatus = statusServiceInterface.update(statusList);
clearedStatus.stream().forEach(s -> { clearedStatus.stream().forEach(s -> {
LOG.info("Cleared Status {}", s.toPrettyString()); LOG.info("Cleared Status Data {}", s.toPrettyString());
}); });
List<Status> customerDashboardStatus = statusServiceInterface.getForEquipment(customerId, Set.of(equipmentId),
List<Status> customerDashboardStatus = statusServiceInterface.getForEquipment(customerId, Set.of(equipmentId), Set.of(StatusDataType.CUSTOMER_DASHBOARD)); Set.of(StatusDataType.CUSTOMER_DASHBOARD));
for (Status status : customerDashboardStatus) { for (Status customerDashStatus : customerDashboardStatus) {
LOG.info("Updated status {}", statusServiceInterface.update(status) ); LOG.info("Updated customer status {}", statusServiceInterface.update(customerDashStatus));
} }
} }
} }

View File

@@ -1271,8 +1271,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
rtsStartEvent.setServerDnsName(apStreamVideoServer.getServerDnsName()); rtsStartEvent.setServerDnsName(apStreamVideoServer.getServerDnsName());
} }
if (apStreamVideoServer.hasClientMac()) { if (apStreamVideoServer.hasClientMac() && apStreamVideoServer.getClientMac().isValidUtf8()) {
rtsStartEvent.setClientMacAddress(MacAddress.valueOf(apStreamVideoServer.getClientMac().toByteArray())); rtsStartEvent.setClientMacAddress(MacAddress.valueOf(apStreamVideoServer.getClientMac().toStringUtf8()));
} }
if (apStreamVideoServer.hasSessionId()) { if (apStreamVideoServer.hasSessionId()) {
@@ -1383,9 +1383,9 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
StreamingVideoSessionStart apStreamVideoSessionStart = videoVoiceReport.getStreamVideoSessionStart(); StreamingVideoSessionStart apStreamVideoSessionStart = videoVoiceReport.getStreamVideoSessionStart();
RealTimeStreamingStartSessionEvent rtsStartSessionEvent = new RealTimeStreamingStartSessionEvent(customerId, RealTimeStreamingStartSessionEvent rtsStartSessionEvent = new RealTimeStreamingStartSessionEvent(customerId,
equipmentId, eventTimestamp); equipmentId, eventTimestamp);
if (apStreamVideoSessionStart.hasClientMac()) { if (apStreamVideoSessionStart.hasClientMac() && apStreamVideoSessionStart.getClientMac().isValidUtf8()) {
rtsStartSessionEvent.setClientMacAddress( rtsStartSessionEvent.setClientMacAddress(
MacAddress.valueOf(apStreamVideoSessionStart.getClientMac().toByteArray())); MacAddress.valueOf(apStreamVideoSessionStart.getClientMac().toStringUtf8()));
} }
if (apStreamVideoSessionStart.hasServerIp()) { if (apStreamVideoSessionStart.hasServerIp()) {
@@ -1422,8 +1422,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
StreamingVideoStop apStreamVideoStop = videoVoiceReport.getStreamVideoStop(); StreamingVideoStop apStreamVideoStop = videoVoiceReport.getStreamVideoStop();
RealTimeStreamingStopEvent rtsStopEvent = new RealTimeStreamingStopEvent(customerId, equipmentId, RealTimeStreamingStopEvent rtsStopEvent = new RealTimeStreamingStopEvent(customerId, equipmentId,
eventTimestamp); eventTimestamp);
if (apStreamVideoStop.hasClientMac()) { if (apStreamVideoStop.hasClientMac() && apStreamVideoStop.getClientMac().isValidUtf8()) {
rtsStopEvent.setClientMacAddress(MacAddress.valueOf(apStreamVideoStop.getClientMac().toByteArray())); rtsStopEvent.setClientMacAddress(MacAddress.valueOf(apStreamVideoStop.getClientMac().toStringUtf8()));
} }
if (apStreamVideoStop.hasDurationSec()) { if (apStreamVideoStop.hasDurationSec()) {