Adding Classification type for Client based on DHCP_leased_IP

Adding translation utility to map between ovsdb and wlan cloud for firmware upgrade state and failure state (if required)
This commit is contained in:
Mike Hansen
2020-09-17 16:30:32 -04:00
parent 4cbb5e1d97
commit ce14eb359d
4 changed files with 229 additions and 191 deletions

View File

@@ -1207,109 +1207,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return;
}
EquipmentUpgradeState fwUpgradeState = EquipmentUpgradeState.undefined;
int upgradeStatusFromAp = opensyncAPState.getUpgradeStatus();
EquipmentUpgradeState fwUpgradeState = OvsdbToWlanCloudTypeMappingUtility
.getCloudEquipmentUpgradeStateFromOpensyncUpgradeStatus(upgradeStatusFromAp);
FailureReason fwUpgradeFailureReason = null;
switch (opensyncAPState.getUpgradeStatus()) {
case 0:
break; // nothing
case -1:
LOG.error("upgrade_status: Wrong arguments (app error)");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.downloadRequestRejected;
break;
case -3:
LOG.error("upgrade_status: Incorrect URL)");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.unreachableUrl;
break;
case -4:
LOG.error("upgrade_status: Failed firmware image download");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.downloadFailed;
break;
case -5:
LOG.error("upgrade_status: Error while downloading firmware md5 sum file");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.downloadFailed;
break;
case -6:
LOG.error("upgrade_status: md5 checksum file error");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.validationFailed;
break;
case -7:
LOG.error("upgrade_status: Firmware image error");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.validationFailed;
break;
case -8:
LOG.error("upgrade_status: Flash erase failed");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.applyFailed;
break;
case -9:
LOG.error("upgrade_status: Flash write failed");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.applyFailed;
break;
case -10:
LOG.error("upgrade_status: Flash verification failed");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.validationFailed;
break;
case -11:
LOG.error("upgrade_status: Set new bootconfig failed");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.applyFailed;
break;
case -12:
LOG.error("upgrade_status: Device restart failed");
fwUpgradeState = EquipmentUpgradeState.reboot_failed;
fwUpgradeFailureReason = FailureReason.rebootTimedout;
break;
case -14:
LOG.error("upgrade_status: Flash BootConfig erase failed");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.applyFailed;
break;
case -15:
LOG.error("upgrade_status: Safe update is running");
fwUpgradeState = EquipmentUpgradeState.apply_failed;
fwUpgradeFailureReason = FailureReason.applyFailed;
break;
case -16:
LOG.error("upgrade_status: Not enough free space on device");
fwUpgradeState = EquipmentUpgradeState.download_failed;
fwUpgradeFailureReason = FailureReason.downloadRequestFailedFlashFull;
break;
case 10:
LOG.info("upgrade_status: Firmware download started for AP {}", apId);
fwUpgradeState = EquipmentUpgradeState.download_initiated;
break;
case 11:
LOG.info("upgrade_status: Firmware download successful, triggering upgrade.");
fwUpgradeState = EquipmentUpgradeState.download_complete;
break;
case 20:
LOG.info("upgrade_status: FW write on alt partition started");
fwUpgradeState = EquipmentUpgradeState.apply_initiated;
break;
case 21:
LOG.info("upgrade_status: FW image write successfully completed");
fwUpgradeState = EquipmentUpgradeState.apply_complete;
break;
case 30:
LOG.info("upgrade_status: Bootconfig partition update started");
fwUpgradeState = EquipmentUpgradeState.apply_initiated;
break;
case 31:
LOG.info("upgrade_status: Bootconfig partition update completed");
fwUpgradeState = EquipmentUpgradeState.apply_complete;
break;
default:
LOG.debug("upgrade_status: {}", opensyncAPState.getUpgradeStatus());
if (upgradeStatusFromAp < 0) {
fwUpgradeFailureReason = OvsdbToWlanCloudTypeMappingUtility
.getCloudEquipmentUpgradeFailureReasonFromOpensyncUpgradeStatus(upgradeStatusFromAp);
}
Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
@@ -1687,7 +1593,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
DhcpFpDeviceType dhcpFpDeviceType = DhcpFpDeviceType
.getById(Integer.valueOf(dhcpLeasedIps.get("device_type")));
.getByName(dhcpLeasedIps.get("device_type"));
ClientType clientType = OvsdbToWlanCloudTypeMappingUtility
.getClientTypeForDhcpFpDeviceType(dhcpFpDeviceType);
@@ -1733,6 +1639,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
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.create(client);
@@ -1792,6 +1712,19 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
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);
@@ -1870,6 +1803,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (dhcpLeasedIps.containsKey("hostname")) {
clientSessionDetails.setHostname(dhcpLeasedIps.get("hostname"));
@@ -1928,23 +1862,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (dhcpLeasedIps.containsKey("vendor_class")) {
clientSessionDetails.setClassificationName(dhcpLeasedIps.get("vendor_class"));
}
if (dhcpLeasedIps.containsKey("db_status")) {
LOG.info("DHCP_leased_IP db_status {}", dhcpLeasedIps.get("db_status"));
}
if (dhcpLeasedIps.containsKey("device_name")) {
LOG.info("DHCP_leased_IP device_name {}", dhcpLeasedIps.get("device_name"));
clientSessionDetails.setClassificationName(dhcpLeasedIps.get("device_name"));
}
if (dhcpLeasedIps.containsKey("device_type")) {
LOG.info("DHCP_leased_IP device_type {}", dhcpLeasedIps.get("device_type"));
}
if (dhcpLeasedIps.containsKey("manuf_id")) {
LOG.info("DHCP_leased_IP manuf_id {}", dhcpLeasedIps.get("manuf_id"));
}
clientSessionDetails.setDhcpDetails(clientDhcpDetails);

View File

@@ -82,7 +82,6 @@ import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeStrea
import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeStreamingStopEvent;
import com.telecominfraproject.wlan.systemevent.equipment.realtime.SIPCallReportReason;
import com.telecominfraproject.wlan.systemevent.equipment.realtime.SipCallStopReason;
import com.telecominfraproject.wlan.systemevent.equipment.realtime.StreamingVideoType;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
import sts.OpensyncStats;
@@ -1087,8 +1086,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}
}
if (apStreamVideoServer.hasStreamingVideoType()) {
rtsStartEvent
.setType(getCloudStreamingVideoTypeFromApReport(apStreamVideoServer.getStreamingVideoType()));
rtsStartEvent.setType(OvsdbToWlanCloudTypeMappingUtility
.getCloudStreamingVideoTypeFromApReport(apStreamVideoServer.getStreamingVideoType()));
}
if (apStreamVideoServer.hasServerDnsName()) {
@@ -1140,8 +1139,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}
if (apStreamVideoSessionStart.hasStreamingVideoType()) {
rtsStartSessionEvent.setType(
getCloudStreamingVideoTypeFromApReport(apStreamVideoSessionStart.getStreamingVideoType()));
rtsStartSessionEvent.setType(OvsdbToWlanCloudTypeMappingUtility
.getCloudStreamingVideoTypeFromApReport(apStreamVideoSessionStart.getStreamingVideoType()));
}
@@ -1181,7 +1180,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
if (apStreamVideoStop.hasStreamingVideoType()) {
rtsStopEvent.setType(getCloudStreamingVideoTypeFromApReport(apStreamVideoStop.getStreamingVideoType()));
rtsStopEvent.setType(OvsdbToWlanCloudTypeMappingUtility
.getCloudStreamingVideoTypeFromApReport(apStreamVideoStop.getStreamingVideoType()));
}
@@ -1198,24 +1198,6 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}
}
private StreamingVideoType getCloudStreamingVideoTypeFromApReport(
sts.OpensyncStats.StreamingVideoType apReportStreamingVideoType) {
switch (apReportStreamingVideoType) {
case NETFLIX:
return StreamingVideoType.NETFLIX;
case YOUTUBE:
return StreamingVideoType.YOUTUBE;
case PLEX:
return StreamingVideoType.PLEX;
case UNKNOWN:
return StreamingVideoType.UNKNOWN;
default:
return StreamingVideoType.UNSUPPORTED;
}
}
void populateApNodeMetrics(List<ServiceMetric> metricRecordList, Report report, int customerId, long equipmentId,
long locationId) {
@@ -1255,7 +1237,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
if (deviceReport.hasCpuUtil() && deviceReport.getCpuUtil().hasCpuUtil()) {
Integer cpuUtilization = deviceReport.getCpuUtil().getCpuUtil();
apPerformance.setCpuUtilized(new int[] { cpuUtilization.intValue() });
apPerformance.setCpuUtilized(new int[] { cpuUtilization });
}
apPerformance.setEthLinkState(EthernetLinkState.UP1000_FULL_DUPLEX);
@@ -1451,20 +1433,8 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
// TODO not totally correct, NonWifi = totalBusy - iBSS - oBSS
radioUtil.setNonWifi(surveySample.getBusy() - surveySample.getBusyTx() - surveySample.getBusySelf());
switch (survey.getBand()) {
case BAND2G:
radioType = RadioType.is2dot4GHz;
break;
case BAND5G:
radioType = RadioType.is5GHz;
break;
case BAND5GL:
radioType = RadioType.is5GHzL;
break;
case BAND5GU:
radioType = RadioType.is5GHzU;
break;
}
radioType = OvsdbToWlanCloudTypeMappingUtility
.getRadioTypeFromOpensyncStatsRadioBandType(survey.getBand());
if (radioType != RadioType.UNSUPPORTED) {
@@ -1485,7 +1455,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}
if (totalDurationMs > 0) {
Long totalUtilization = Math.round((double) totalBusy / totalDurationMs);
Long totalNonWifi = Math.round((double) totalBusy - (double) iBSS - (double) oBSS / totalDurationMs);
Long totalNonWifi = Math.round((double) totalBusy - (double) iBSS - ((double) oBSS / totalDurationMs));
EquipmentCapacityDetails cap = new EquipmentCapacityDetails();
cap.setUnavailableCapacity(totalNonWifi.intValue());
@@ -1555,7 +1525,7 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
if (dnsProbeMetricFromAp.hasState()) {
StateUpDownError dnsState = OvsdbToWlanCloudTypeMappingUtility
.getCloudDnsStateFromOpensyncStatsStateUpDown(dnsProbeMetricFromAp.getState());
.getCloudMetricsStateFromOpensyncStatsStateUpDown(dnsProbeMetricFromAp.getState());
networkProbeMetrics.setDnsState(dnsState);
cloudDnsProbeMetric.setDnsState(dnsState);
@@ -1584,18 +1554,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
}
if (radiusMetrics.hasRadiusState()) {
switch (radiusMetrics.getRadiusState()) {
case SUD_down:
networkProbeMetrics.setRadiusState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setRadiusState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setRadiusState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setRadiusState(StateUpDownError.UNSUPPORTED);
if (radiusMetrics.hasRadiusState()) {
StateUpDownError radiusState = OvsdbToWlanCloudTypeMappingUtility
.getCloudMetricsStateFromOpensyncStatsStateUpDown(radiusMetrics.getRadiusState());
networkProbeMetrics.setRadiusState(radiusState);
}
}
@@ -1607,20 +1571,12 @@ public class OpensyncExternalIntegrationMqttMessageProcessor {
networkProbeMetrics.setVlanIF(vlanMetrics.getVlanIF());
}
if (vlanMetrics.hasDhcpState()) {
StateUpDownError dhcpState = OvsdbToWlanCloudTypeMappingUtility
.getCloudMetricsStateFromOpensyncStatsStateUpDown(vlanMetrics.getDhcpState());
networkProbeMetrics.setDhcpState(dhcpState);
switch (vlanMetrics.getDhcpState()) {
case SUD_down:
networkProbeMetrics.setDhcpState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setDhcpState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setDhcpState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setDhcpState(StateUpDownError.UNSUPPORTED);
}
}
if (vlanMetrics.hasLatency()) {
networkProbeMetrics.setDhcpLatencyMs(vlanMetrics.getLatency());

View File

@@ -49,6 +49,12 @@
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
<dependency>
<artifactId>status-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java-util -->
<dependency>
<groupId>com.google.protobuf</groupId>

View File

@@ -3,8 +3,11 @@ package com.telecominfraproject.wlan.opensync.ovsdb.dao.utilities;
import com.telecominfraproject.wlan.client.models.ClientType;
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.enumerations.DhcpFpDeviceType;
//import com.telecominfraproject.wlan.servicemetric.apnode.models.StateUpDownError;
import com.telecominfraproject.wlan.servicemetric.apnode.models.StateUpDownError;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState.FailureReason;
import com.telecominfraproject.wlan.systemevent.equipment.realtime.StreamingVideoType;
import sts.OpensyncStats.RadioBandType;
import sts.OpensyncStats.StateUpDown;
@@ -76,7 +79,7 @@ public class OvsdbToWlanCloudTypeMappingUtility {
}
}
public static StateUpDownError getCloudDnsStateFromOpensyncStatsStateUpDown(StateUpDown apNetworkProbeState) {
public static StateUpDownError getCloudMetricsStateFromOpensyncStatsStateUpDown(StateUpDown apNetworkProbeState) {
switch (apNetworkProbeState) {
case SUD_down:
return StateUpDownError.disabled;
@@ -92,4 +95,157 @@ public class OvsdbToWlanCloudTypeMappingUtility {
}
public static StreamingVideoType getCloudStreamingVideoTypeFromApReport(
sts.OpensyncStats.StreamingVideoType apReportStreamingVideoType) {
switch (apReportStreamingVideoType) {
case NETFLIX:
return StreamingVideoType.NETFLIX;
case YOUTUBE:
return StreamingVideoType.YOUTUBE;
case PLEX:
return StreamingVideoType.PLEX;
case UNKNOWN:
return StreamingVideoType.UNKNOWN;
default:
return StreamingVideoType.UNSUPPORTED;
}
}
public static EquipmentUpgradeState getCloudEquipmentUpgradeStateFromOpensyncUpgradeStatus(int upgradeStatus) {
EquipmentUpgradeState ret = EquipmentUpgradeState.undefined;
switch (upgradeStatus) {
case 0:
break; // nothing
case -1:
ret = EquipmentUpgradeState.download_failed;
break;
case -3:
ret = EquipmentUpgradeState.download_failed;
break;
case -4:
ret = EquipmentUpgradeState.download_failed;
break;
case -5:
ret = EquipmentUpgradeState.download_failed;
break;
case -6:
ret = EquipmentUpgradeState.download_failed;
break;
case -7:
ret = EquipmentUpgradeState.apply_failed;
break;
case -8:
ret = EquipmentUpgradeState.apply_failed;
break;
case -9:
ret = EquipmentUpgradeState.apply_failed;
break;
case -10:
ret = EquipmentUpgradeState.apply_failed;
break;
case -11:
ret = EquipmentUpgradeState.apply_failed;
break;
case -12:
ret = EquipmentUpgradeState.reboot_failed;
break;
case -14:
ret = EquipmentUpgradeState.apply_failed;
break;
case -15:
ret = EquipmentUpgradeState.apply_failed;
break;
case -16:
ret = EquipmentUpgradeState.download_failed;
break;
case 10:
ret = EquipmentUpgradeState.download_initiated;
break;
case 11:
ret = EquipmentUpgradeState.download_complete;
break;
case 20:
ret = EquipmentUpgradeState.apply_initiated;
break;
case 21:
ret = EquipmentUpgradeState.apply_complete;
break;
case 30:
ret = EquipmentUpgradeState.apply_initiated;
break;
case 31:
ret = EquipmentUpgradeState.apply_complete;
break;
default:
}
return ret;
}
public static EquipmentUpgradeState.FailureReason getCloudEquipmentUpgradeFailureReasonFromOpensyncUpgradeStatus(
int upgradeStatus) {
EquipmentUpgradeState.FailureReason ret = null;
switch (upgradeStatus) {
case 0:
break; // nothing
case -1:
ret = FailureReason.downloadRequestRejected;
break;
case -3:
ret = FailureReason.unreachableUrl;
break;
case -4:
ret = FailureReason.downloadFailed;
break;
case -5:
ret = FailureReason.downloadFailed;
break;
case -6:
ret = FailureReason.validationFailed;
break;
case -7:
ret = FailureReason.validationFailed;
break;
case -8:
ret = FailureReason.applyFailed;
break;
case -9:
ret = FailureReason.applyFailed;
break;
case -10:
ret = FailureReason.validationFailed;
break;
case -11:
ret = FailureReason.applyFailed;
break;
case -12:
ret = FailureReason.rebootTimedout;
break;
case -14:
ret = FailureReason.applyFailed;
break;
case -15:
ret = FailureReason.applyFailed;
break;
case -16:
ret = FailureReason.downloadRequestFailedFlashFull;
break;
default:
}
return ret;
}
}