mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-10-30 18:17:59 +00:00 
			
		
		
		
	OpensyncGatewayController:
Control LED off via Equipment AP profile and Show LED status in EQUIPMENT_ADMIN status Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
This commit is contained in:
		| @@ -103,6 +103,7 @@ import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolSta | ||||
| import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState; | ||||
| import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState.FailureReason; | ||||
| import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeStatusData; | ||||
| import com.telecominfraproject.wlan.status.equipment.models.LedStatus; | ||||
| 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; | ||||
| @@ -115,12 +116,8 @@ import com.telecominfraproject.wlan.status.models.StatusCode; | ||||
| import com.telecominfraproject.wlan.status.models.StatusDataType; | ||||
| import com.telecominfraproject.wlan.status.network.models.NetworkAdminStatusData; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.ApcElectionEvent; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeEventType; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.ApcElectionEvent.ApcMode; | ||||
|  | ||||
| import sts.OpensyncStats.Report; | ||||
| import traffic.NetworkMetadata.FlowReport; | ||||
| import wc.stats.IpDnsTelemetry.WCStatsReport; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeEventType; | ||||
|  | ||||
| @org.springframework.context.annotation.Profile("opensync_cloud_config") | ||||
| @Component | ||||
| @@ -182,7 +179,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|  | ||||
|     @Override | ||||
|     public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) { | ||||
|     	 | ||||
|  | ||||
|         Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); | ||||
|  | ||||
|         try { | ||||
| @@ -511,6 +508,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             } | ||||
|  | ||||
|             ((EquipmentAdminStatusData) statusRecord.getDetails()).setStatusCode(StatusCode.normal); | ||||
|             if (((EquipmentAdminStatusData) statusRecord.getDetails()).getLedStatus() == null) { | ||||
|                 ((EquipmentAdminStatusData) statusRecord.getDetails()).setLedStatus(LedStatus.UNKNOWN); | ||||
|             } | ||||
|             // Update the equipment admin status | ||||
|             statusRecord = statusServiceInterface.update(statusRecord); | ||||
|  | ||||
| @@ -890,20 +890,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|     private void updateApDisconnectedStatus(String apId, Equipment ce) { | ||||
|         LOG.info("updateApDisconnectedStatus disconnected AP {}", apId); | ||||
|         try { | ||||
|         	Alarm disconnectedAlarm = new Alarm(); | ||||
|             Alarm disconnectedAlarm = new Alarm(); | ||||
|             disconnectedAlarm.setCustomerId(ce.getCustomerId()); | ||||
|             disconnectedAlarm.setEquipmentId(ce.getId()); | ||||
|             disconnectedAlarm.setAlarmCode(AlarmCode.Disconnected); | ||||
|              | ||||
|  | ||||
|             AlarmDetails alarmDetails = new AlarmDetails(); | ||||
|     		alarmDetails.setMessage(AlarmCode.Disconnected.getDescription()); | ||||
|     		alarmDetails.setAffectedEquipmentIds(List.of(ce.getId())); | ||||
|     		alarmDetails.setGeneratedBy(apId); | ||||
|     		 | ||||
|     		disconnectedAlarm.setDetails(alarmDetails); | ||||
|              | ||||
|     		alarmServiceInterface.create(disconnectedAlarm); | ||||
|              | ||||
|             alarmDetails.setMessage(AlarmCode.Disconnected.getDescription()); | ||||
|             alarmDetails.setAffectedEquipmentIds(List.of(ce.getId())); | ||||
|             alarmDetails.setGeneratedBy(apId); | ||||
|  | ||||
|             disconnectedAlarm.setDetails(alarmDetails); | ||||
|  | ||||
|             alarmServiceInterface.create(disconnectedAlarm); | ||||
|  | ||||
|             Status statusRecord = new Status(); | ||||
|             statusRecord.setCustomerId(ce.getCustomerId()); | ||||
|             statusRecord.setEquipmentId(ce.getId()); | ||||
| @@ -1080,7 +1080,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             return; // we don't have the required info to get the | ||||
|             // radio type yet | ||||
|         } | ||||
|          | ||||
|  | ||||
|         int customerId = apNode.getCustomerId(); | ||||
|  | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
| @@ -1088,7 +1088,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         ApElementConfiguration apElementConfig = (ApElementConfiguration) apNode.getDetails(); | ||||
|  | ||||
|         ProfileContainer profileContainer = new ProfileContainer(profileServiceInterface.getProfileWithChildren(apNode.getProfileId())); | ||||
| @@ -1218,15 +1217,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get Equipment for AP {}", apId); | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         int customerId = ce.getCustomerId(); | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
|             LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         ApElementConfiguration apElementConfiguration = ((ApElementConfiguration) ce.getDetails()); | ||||
|  | ||||
|         boolean configStateMismatch = false; | ||||
| @@ -1445,15 +1442,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             LOG.debug("wifiInetStateDbTableUpdate Cannot get customer Equipment for {}", apId); | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         int customerId = ce.getCustomerId(); | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
|             LOG.debug("wifiInetStateDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         Status lanStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.LANINFO); | ||||
|         if (lanStatus == null) { | ||||
|             lanStatus = new Status(); | ||||
| @@ -1567,8 +1562,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|         if (ovsdbSession == null) { | ||||
|             LOG.debug("wifiAssociatedClientsDbTableUpdate::Cannot get Session for AP {}", apId); | ||||
|             return; | ||||
|         }     | ||||
|          | ||||
|         } | ||||
|  | ||||
|         long equipmentId = ovsdbSession.getEquipmentId(); | ||||
|         Equipment ce = equipmentServiceInterface.getOrNull(equipmentId); | ||||
|  | ||||
| @@ -1576,15 +1571,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             LOG.debug("wifiAssociatedClientsDbTableUpdate Cannot get customer Equipment for {}", apId); | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         int customerId = ce.getCustomerId(); | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
|             LOG.debug("wifiAssociatedClientsDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         if ((wifiAssociatedClients == null) || wifiAssociatedClients.isEmpty()) { | ||||
|             return; | ||||
|         } | ||||
| @@ -1678,8 +1671,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         int upgradeStatusFromAp = node.getUpgradeStatus(); | ||||
|         EquipmentUpgradeState fwUpgradeState = null; | ||||
|         FailureReason fwUpgradeFailureReason = null; | ||||
| @@ -2007,8 +1998,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         long locationId = ce.getLocationId(); | ||||
|  | ||||
|         if (rowUpdateOperation.equals(RowUpdateOperation.INSERT) || rowUpdateOperation.equals(RowUpdateOperation.MODIFY) | ||||
| @@ -2378,20 +2367,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|     @Override | ||||
|     public void apcStateDbTableUpdate(Map<String, String> apcStateAttributes, String apId, RowUpdateOperation rowUpdateOperation) { | ||||
|         LOG.info("apcStateDbTableUpdate {} operations on AP {} with values {} ", rowUpdateOperation, apId, apcStateAttributes); | ||||
|          | ||||
|  | ||||
|         OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); | ||||
|         if (ovsdbSession == null) { | ||||
|             LOG.info("apcStateDbTableUpdate::Cannot get Session for AP {}", apId); | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         long equipmentId = ovsdbSession.getEquipmentId(); | ||||
|         Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); | ||||
|         if (ce == null) { | ||||
|             LOG.info("apcStateDbTableUpdate::Cannot get Equipment for AP {}", apId); | ||||
|             return; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         int customerId = ce.getCustomerId(); | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
|             LOG.info("apcStateDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); | ||||
| @@ -2432,4 +2421,59 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|                         RealTimeEventType.APC_Election_event, customerId, ce.getLocationId(), equipmentId, System.currentTimeMillis()); | ||||
|         mqttMessageProcessor.publishSystemEventFromTableStateMonitor(electionEvent); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void nodeStateDbTableUpdate(List<Map<String, String>> nodeStateAttributes, String apId) { | ||||
|         LOG.debug("start nodeStateDbTableUpdate for {}", apId); | ||||
|         if (LOG.isTraceEnabled()) | ||||
|             LOG.trace("nodeStateDbTableUpdate tableAttributes {}", nodeStateAttributes); | ||||
|  | ||||
|         OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); | ||||
|         if (ovsdbSession == null) { | ||||
|             LOG.warn("nodeStateDbTableUpdate::Cannot get Session for AP {}", apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         long equipmentId = ovsdbSession.getEquipmentId(); | ||||
|         Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); | ||||
|         if (ce == null) { | ||||
|             LOG.warn("nodeStateDbTableUpdate::Cannot get Equipment for AP {}", apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         int customerId = ce.getCustomerId(); | ||||
|         if ((customerId < 0) || (equipmentId < 0)) { | ||||
|             LOG.warn("nodeStateDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         Status eqAdminStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.EQUIPMENT_ADMIN); | ||||
|  | ||||
|         LedStatus ledStatus = null; | ||||
|         for (Map<String, String> nsa : nodeStateAttributes) { | ||||
|             if (nsa.get("module").equals("led")) { | ||||
|                 if (nsa.get("key").equals("led_blink") && nsa.get("value").equals("on")) { | ||||
|                     ledStatus = LedStatus.led_blink; | ||||
|                 } else if (nsa.get("key").equals("led_off") && nsa.get("value").equals("off")) { | ||||
|                     ledStatus = LedStatus.led_off; | ||||
|                 } else { | ||||
|                     ledStatus = LedStatus.UNKNOWN; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (ledStatus != null) { | ||||
|             if (eqAdminStatus != null) { | ||||
|                 if (((EquipmentAdminStatusData) eqAdminStatus.getDetails()).getLedStatus() == null | ||||
|                         || !((EquipmentAdminStatusData) eqAdminStatus.getDetails()).getLedStatus().equals(ledStatus)) { | ||||
|                     ((EquipmentAdminStatusData) eqAdminStatus.getDetails()).setLedStatus(ledStatus); | ||||
|                     eqAdminStatus = statusServiceInterface.update(eqAdminStatus); | ||||
|                     LOG.debug("nodeStateDbTableUpdate updated status {}", eqAdminStatus); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         LOG.debug("finished nodeStateDbTableUpdate for {}", apId); | ||||
|  | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -50,6 +50,8 @@ public interface OpensyncExternalIntegrationInterface { | ||||
|  | ||||
|     void apcStateDbTableUpdate(Map<String, String> apcStateAttributes, String apId, | ||||
|             RowUpdateOperation rowUpdateOperation); | ||||
|      | ||||
|     void nodeStateDbTableUpdate(List<Map<String, String>> nodeStateAttributes, String apId); | ||||
|  | ||||
|     void clearEquipmentStatus(String apId); | ||||
| } | ||||
|   | ||||
| @@ -207,4 +207,9 @@ public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegr | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void nodeStateDbTableUpdate(List<Map<String, String>> nodeStateAttributes, String apId) { | ||||
|         LOG.info("nodeStateDbTableUpdate for AP {}", apId); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import com.vmware.ovsdb.callback.ConnectionCallback; | ||||
| import com.vmware.ovsdb.exception.OvsdbClientException; | ||||
| import com.vmware.ovsdb.protocol.methods.*; | ||||
| import com.vmware.ovsdb.protocol.operation.notation.Row; | ||||
| import com.vmware.ovsdb.protocol.operation.notation.Value; | ||||
| import com.vmware.ovsdb.service.OvsdbClient; | ||||
| import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener; | ||||
| import io.netty.handler.ssl.SslContext; | ||||
| @@ -258,7 +259,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { | ||||
|             ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig); | ||||
|             if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) { | ||||
|                 ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); | ||||
|             }         | ||||
|             } | ||||
|             ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient); | ||||
|             ovsdbDao.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent); | ||||
|  | ||||
| @@ -288,7 +289,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { | ||||
|  | ||||
|         return ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress); | ||||
|     } | ||||
|      | ||||
|  | ||||
|     public String processBlinkRequest(String apId, boolean blinkAllLEDs) { | ||||
|         OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); | ||||
|         if (ovsdbSession == null) { | ||||
| @@ -717,20 +718,35 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { | ||||
|         CompletableFuture<TableUpdates> nsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, OvsdbDao.nodeStateTable + "_" + key, | ||||
|                 new MonitorRequests(ImmutableMap.of(OvsdbDao.nodeStateTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), tableUpdates -> { | ||||
|                     LOG.info(OvsdbDao.nodeStateTable + "_" + key + " monitor callback received {}"); | ||||
|                     tableUpdates.getTableUpdates().forEach((key1, value) -> { | ||||
|                         LOG.info("TableUpdate for {}", key1); | ||||
|                         value.getRowUpdates().values().forEach(r -> { | ||||
|                             if (r.getOld() != null) { | ||||
|                                 LOG.info("Node_State old row {}", r.getOld().getColumns()); | ||||
|                             } | ||||
|                             if (r.getNew() != null) { | ||||
|                                 LOG.info("Node_State new row {}", r.getNew().getColumns()); | ||||
|                             } | ||||
|                         }); | ||||
|  | ||||
|                     }); | ||||
|                     extIntegrationInterface.nodeStateDbTableUpdate(processNodeStateTableUpdate(key, tableUpdates), key); | ||||
|                      | ||||
|                 }); | ||||
|         nsCf.join(); | ||||
|         extIntegrationInterface.nodeStateDbTableUpdate(processNodeStateTableUpdate(key, nsCf.join()), key); | ||||
|     } | ||||
|  | ||||
|     private List<Map<String,String>> processNodeStateTableUpdate(String key, TableUpdates tableUpdates) { | ||||
|         List<Map<String, String>> updates = new ArrayList<>(); | ||||
|         tableUpdates.getTableUpdates().forEach((key1, value) -> { | ||||
|             LOG.info("TableUpdate for {}", key1); | ||||
|             value.getRowUpdates().values().forEach(r -> { | ||||
|                 if (r.getOld() != null) { | ||||
|                     LOG.info("Node_State old row {}", r.getOld().getColumns()); | ||||
|                 } | ||||
|                 if (r.getNew() != null) { | ||||
|                     LOG.info("Node_State new row {}", r.getNew().getColumns()); | ||||
|                     Map<String, Value> columns = r.getNew().getColumns(); | ||||
|                     Map<String, String> update = new HashMap<>(); | ||||
|                     update.put("key", columns.get("key").toString()); | ||||
|                     update.put("module", columns.get("module").toString()); | ||||
|                     update.put("persist", columns.get("persist").toString()); | ||||
|                     update.put("value", columns.get("value").toString()); | ||||
|                     updates.add(update); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|         }); | ||||
|          | ||||
|         return updates; | ||||
|     } | ||||
|  | ||||
|     private void monitorAPCStateTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { | ||||
|   | ||||
| @@ -9,6 +9,7 @@ import org.springframework.stereotype.Component; | ||||
|  | ||||
| import com.telecominfraproject.wlan.core.model.equipment.MacAddress; | ||||
| import com.telecominfraproject.wlan.core.model.equipment.RadioType; | ||||
| import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration; | ||||
| import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes; | ||||
| import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo; | ||||
| import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig; | ||||
| @@ -86,7 +87,10 @@ public class OvsdbDao extends OvsdbDaoBase { | ||||
|     } | ||||
|      | ||||
|     public void configureNode(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) { | ||||
|         configureNtpServer(ovsdbClient,opensyncAPConfig);configureSyslog(ovsdbClient, opensyncAPConfig); | ||||
|         configureNtpServer(ovsdbClient, opensyncAPConfig); | ||||
|         configureSyslog(ovsdbClient, opensyncAPConfig); | ||||
|         processBlinkRequest(ovsdbClient, opensyncAPConfig.getCustomerEquipment().getInventoryId(), | ||||
|                 ((ApElementConfiguration) opensyncAPConfig.getCustomerEquipment().getDetails()).isBlinkAllLEDs()); | ||||
|     } | ||||
|      | ||||
|     void configureNtpServer(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mike Hansen
					Mike Hansen