mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 19:17:52 +00:00
WIFI-1110: vifS is not applying as wm is crashing due to garbage in /etc/wireless/config -- removing short-term caching of Equipment from OpensyncGatewayExternalCloud
This commit is contained in:
@@ -11,14 +11,10 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cache.Cache;
|
|
||||||
import org.springframework.cache.CacheManager;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@@ -158,32 +154,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.ovsdb.wifi-iface.default_wan_name:wan}")
|
@org.springframework.beans.factory.annotation.Value("${tip.wlan.ovsdb.wifi-iface.default_wan_name:wan}")
|
||||||
public String defaultWanInterfaceName;
|
public String defaultWanInterfaceName;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CacheManager cacheManagerShortLived;
|
|
||||||
private Cache cloudEquipmentRecordCache;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void postCreate() {
|
|
||||||
LOG.info("Using Cloud integration");
|
|
||||||
cloudEquipmentRecordCache = cacheManagerShortLived.getCache("equipment_record_cache");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Equipment getCustomerEquipment(String apId) {
|
|
||||||
Equipment ce = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
ce = cloudEquipmentRecordCache.get(apId, () -> equipmentServiceInterface.getByInventoryIdOrNull(apId));
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("Could not get customer equipment for {}", apId, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ce;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) {
|
public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) {
|
||||||
|
|
||||||
Equipment ce = getCustomerEquipment(apId);
|
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (ce == null) {
|
if (ce == null) {
|
||||||
@@ -300,10 +274,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
ce = equipmentServiceInterface.create(ce);
|
ce = equipmentServiceInterface.create(ce);
|
||||||
|
|
||||||
// update the cache right away, no need to wait until the
|
|
||||||
// entry expires
|
|
||||||
cloudEquipmentRecordCache.put(ce.getInventoryId(), ce);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// equipment already exists
|
// equipment already exists
|
||||||
|
|
||||||
@@ -324,9 +294,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
ce.setBaseMacAddress(reportedMacAddress);
|
ce.setBaseMacAddress(reportedMacAddress);
|
||||||
ce = equipmentServiceInterface.update(ce);
|
ce = equipmentServiceInterface.update(ce);
|
||||||
|
|
||||||
// update the cache right away, no need to wait
|
|
||||||
// until the entry expires
|
|
||||||
cloudEquipmentRecordCache.put(ce.getInventoryId(), ce);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +301,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
|
|
||||||
EquipmentRoutingRecord equipmentRoutingRecord = gatewayController.registerCustomerEquipment(ce.getName(),
|
EquipmentRoutingRecord equipmentRoutingRecord = gatewayController.registerCustomerEquipment(ce.getName(),
|
||||||
ce.getCustomerId(), ce.getId());
|
ce.getCustomerId(), ce.getId());
|
||||||
|
|
||||||
updateApStatus(ce, connectNodeInfo);
|
updateApStatus(ce, connectNodeInfo);
|
||||||
|
|
||||||
removeNonWifiClients(ce, connectNodeInfo);
|
removeNonWifiClients(ce, connectNodeInfo);
|
||||||
@@ -588,7 +555,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
networkAdminStatusRec = statusServiceInterface.update(networkAdminStatusRec);
|
networkAdminStatusRec = statusServiceInterface.update(networkAdminStatusRec);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("Exception in updateApStatus", e);
|
LOG.error("Exception in updateApStatus", e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -762,14 +730,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||||
|
|
||||||
if (ovsdbSession != null) {
|
if (ovsdbSession != null) {
|
||||||
// if (ovsdbSession.getCustomerId() > 0 &&
|
|
||||||
// ovsdbSession.getEquipmentId() > 0L) {
|
|
||||||
// List<Status> statusForDisconnectedAp =
|
|
||||||
// statusServiceInterface.delete(ovsdbSession.getCustomerId(),
|
|
||||||
// ovsdbSession.getEquipmentId());
|
|
||||||
// LOG.info("Deleted status records {} for AP {}",
|
|
||||||
// statusForDisconnectedAp, apId);
|
|
||||||
// }
|
|
||||||
if (ovsdbSession.getRoutingId() > 0L) {
|
if (ovsdbSession.getRoutingId() > 0L) {
|
||||||
try {
|
try {
|
||||||
routingServiceInterface.delete(ovsdbSession.getRoutingId());
|
routingServiceInterface.delete(ovsdbSession.getRoutingId());
|
||||||
@@ -803,7 +763,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
if ((customer != null) && (customer.getDetails() != null)
|
if ((customer != null) && (customer.getDetails() != null)
|
||||||
&& (customer.getDetails().getAutoProvisioning() != null)
|
&& (customer.getDetails().getAutoProvisioning() != null)
|
||||||
&& customer.getDetails().getAutoProvisioning().isEnabled()) {
|
&& customer.getDetails().getAutoProvisioning().isEnabled()) {
|
||||||
Equipment equipmentConfig = getCustomerEquipment(apId);
|
Equipment equipmentConfig = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||||
|
|
||||||
if (equipmentConfig == null) {
|
if (equipmentConfig == null) {
|
||||||
throw new IllegalStateException("Cannot retrieve configuration for " + apId);
|
throw new IllegalStateException("Cannot retrieve configuration for " + apId);
|
||||||
@@ -1466,7 +1426,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Equipment ce = getCustomerEquipment(apId);
|
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||||
if (ce == null) {
|
if (ce == null) {
|
||||||
LOG.info("awlanNodeDbTableUpdate::Cannot find AP {}", apId);
|
LOG.info("awlanNodeDbTableUpdate::Cannot find AP {}", apId);
|
||||||
return;
|
return;
|
||||||
@@ -1762,7 +1722,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Equipment ce = getCustomerEquipment(apId);
|
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||||
|
|
||||||
if (ce == null) {
|
if (ce == null) {
|
||||||
LOG.debug("updateDhcpIpClientFingerprints::Cannot get Equipment for AP {}", apId);
|
LOG.debug("updateDhcpIpClientFingerprints::Cannot get Equipment for AP {}", apId);
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ import sts.OpensyncStats.Client;
|
|||||||
import sts.OpensyncStats.ClientReport;
|
import sts.OpensyncStats.ClientReport;
|
||||||
import sts.OpensyncStats.EventReport;
|
import sts.OpensyncStats.EventReport;
|
||||||
import sts.OpensyncStats.EventReport.ClientAssocEvent;
|
import sts.OpensyncStats.EventReport.ClientAssocEvent;
|
||||||
import sts.OpensyncStats.EventType;
|
|
||||||
import sts.OpensyncStats.RadioBandType;
|
import sts.OpensyncStats.RadioBandType;
|
||||||
import sts.OpensyncStats.Report;
|
import sts.OpensyncStats.Report;
|
||||||
|
|
||||||
@@ -162,20 +161,6 @@ public class OpensyncExternalIntegrationCloudTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetCustomerEquipment() {
|
|
||||||
|
|
||||||
Equipment equipment = new Equipment();
|
|
||||||
equipment.setDetails(ApElementConfiguration.createWithDefaults());
|
|
||||||
|
|
||||||
Mockito.when(
|
|
||||||
equipmentServiceInterface.getByInventoryIdOrNull(ArgumentMatchers.eq("Test_Client_21P10C68818122")))
|
|
||||||
.thenReturn(equipment);
|
|
||||||
assertNotNull(opensyncExternalIntegrationCloud.getCustomerEquipment("Test_Client_21P10C68818122"));
|
|
||||||
assertNull(opensyncExternalIntegrationCloud.getCustomerEquipment("Test_Client_21P10C68818133"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApConnected() {
|
public void testApConnected() {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user