mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2026-03-20 19:39:11 +00:00
Compare commits
2 Commits
release/v1
...
WIFI-6721-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91c1b854c5 | ||
|
|
434aa5c557 |
@@ -25,8 +25,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -100,6 +98,7 @@ import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.network.models.RadioProfileConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.rf.models.RfConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.rf.models.RfElementConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration.SecureMode;
|
||||
import com.telecominfraproject.wlan.routing.RoutingServiceInterface;
|
||||
@@ -138,15 +137,12 @@ import sts.OpensyncStats.Report;
|
||||
@Component
|
||||
public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegrationInterface {
|
||||
|
||||
public static final String DERIVED_SESSION_ID_PREFIX = "DERIVED-";
|
||||
protected static final String standard_linux_date_format = "EEE MMM dd HH:mm:ss zzz yyyy";
|
||||
private static final String VLAN_TRUNK_IF_TYPE = "vlan_trunk";
|
||||
private static final String ALLOWED_VLANS = "allowed_vlans";
|
||||
private static final String NATIVE_VLAN_ID = "pvid";
|
||||
private static final String SPACE_SEPERATOR = " ";
|
||||
|
||||
public final static int MAX_ALLOWED_2GHz_CHANNEL_NUMBER = 14;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OpensyncExternalIntegrationCloud.class);
|
||||
|
||||
@Autowired
|
||||
@@ -586,8 +582,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
protocolStatusData.setBandPlan("FCC");
|
||||
protocolStatusData.setBaseMacAddress(MacAddress.valueOf(connectNodeInfo.macAddress));
|
||||
protocolStatusData.setCloudCfgDataVersion(42L);
|
||||
//this will be set later in the flow - after the config is successfully pushed to the AP
|
||||
//protocolStatusData.setReportedCfgDataVersion(42L);
|
||||
protocolStatusData.setReportedCfgDataVersion(42L);
|
||||
CountryCode countryCode = Location.getCountryCode(locationServiceInterface.getOrNull(ce.getLocationId()));
|
||||
if (countryCode != null)
|
||||
protocolStatusData.setCountryCode(countryCode.getName());
|
||||
@@ -771,7 +766,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
String firmwareVersion) {
|
||||
|
||||
LOG.debug("reconcileFwVersionToTrack for AP {} with active firmware version {} model {}", ce.getInventoryId(), activeFirmwareImageAp, model);
|
||||
Status statusRecord = statusServiceInterface.getOrNull(ce.getCustomerId(), ce.getId(), StatusDataType.FIRMWARE);
|
||||
Status statusRecord = statusServiceInterface.getOrNull(autoProvisionedCustomerId, autoProvisionedCustomerId, StatusDataType.FIRMWARE);
|
||||
if (statusRecord == null) {
|
||||
statusRecord = new Status();
|
||||
statusRecord.setCreatedTimestamp(System.currentTimeMillis());
|
||||
@@ -781,7 +776,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
statusRecord.setDetails(new EquipmentUpgradeStatusData());
|
||||
((EquipmentUpgradeStatusData) statusRecord.getDetails()).setActiveSwVersion(activeFirmwareImageAp);
|
||||
if (inactiveFirmwareImageAp != null) {
|
||||
((EquipmentUpgradeStatusData) statusRecord.getDetails()).setAlternateSwVersion(inactiveFirmwareImageAp);
|
||||
((EquipmentUpgradeStatusData) statusRecord.getDetails()).setActiveSwVersion(inactiveFirmwareImageAp);
|
||||
}
|
||||
}
|
||||
EquipmentUpgradeStatusData fwUpgradeStatusData = (EquipmentUpgradeStatusData) statusRecord.getDetails();
|
||||
@@ -799,8 +794,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
// determine if AP requires FW upgrade before cloud
|
||||
// connection/provision
|
||||
if (trackSettings.getAutoUpgradeDeprecatedOnBind().equals(TrackFlag.ALWAYS) || trackSettings.getAutoUpgradeUnknownOnBind().equals(TrackFlag.ALWAYS)) {
|
||||
LOG.debug("reconcileFwVersionToTrack for AP {} track flag for auto-upgrade; deprecated flag {} ; unknown flag {} ", ce.getInventoryId(),
|
||||
trackSettings.getAutoUpgradeDeprecatedOnBind(), trackSettings.getAutoUpgradeUnknownOnBind());
|
||||
LOG.debug("reconcileFwVersionToTrack for AP {} track flag for auto-upgrade {}", ce.getInventoryId(),
|
||||
trackSettings.getAutoUpgradeDeprecatedOnBind());
|
||||
// check the reported fw version for the AP, if it is < than
|
||||
// the default version for the cloud, then download and
|
||||
// flash the firmware before proceeding.
|
||||
@@ -889,17 +884,23 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apDisconnected(String apId, Long ctxRoutingId) {
|
||||
LOG.info("AP {} got disconnected from the gateway, remove ctxRoutingId {} ", apId, ctxRoutingId);
|
||||
public void apDisconnected(String apId) {
|
||||
LOG.info("AP {} got disconnected from the gateway", apId);
|
||||
try {
|
||||
if (ctxRoutingId != null && ctxRoutingId > 0L) {
|
||||
try {
|
||||
routingServiceInterface.delete(ctxRoutingId);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Unable to delete routing service Id {} for ap {}. {}", ctxRoutingId, apId, e);
|
||||
}
|
||||
}
|
||||
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||
|
||||
if (ovsdbSession != null) {
|
||||
if (ovsdbSession.getRoutingId() > 0L) {
|
||||
try {
|
||||
routingServiceInterface.delete(ovsdbSession.getRoutingId());
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Unable to delete routing service Id {} for ap {}. {}", ovsdbSession.getRoutingId(), apId, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG.warn("Cannot find ap {} in inventory", apId);
|
||||
}
|
||||
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||
if (ce != null) {
|
||||
List<Status> deletedStatuses = statusServiceInterface.deleteOnEquipmentDisconnect(ce.getCustomerId(), ce.getId());
|
||||
@@ -915,47 +916,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLatestRoutingId(String apId) {
|
||||
try {
|
||||
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId);
|
||||
if (ce != null) {
|
||||
List<EquipmentRoutingRecord> recordList = routingServiceInterface.getRegisteredRouteList(ce.getId());
|
||||
LOG.info("{} routing records found for AP {}, sort and return latest routingRecordId", recordList.size(), apId);
|
||||
if (!recordList.isEmpty()) {
|
||||
// Sort by latest record first
|
||||
Collections.sort(recordList, new Comparator<EquipmentRoutingRecord>() {
|
||||
@Override
|
||||
public int compare(EquipmentRoutingRecord o1, EquipmentRoutingRecord o2) {
|
||||
return Long.compare(o2.getLastModifiedTimestamp(), o1.getLastModifiedTimestamp());
|
||||
}
|
||||
});
|
||||
return recordList.get(0).getId();
|
||||
} else {
|
||||
LOG.debug("No records found for AP {} equipmentId {}", apId, ce.getId());
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
// Equipment doesn't exist, nothing to clean up
|
||||
LOG.debug("No equipment found for AP {} ", apId);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Exception when registering ap routing {}", apId, e);
|
||||
// Equipment doesn't exist, nothing to clean up
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoutingRecord(Long routingId) {
|
||||
try {
|
||||
routingServiceInterface.delete(routingId);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Unable to delete routing service Id {}. {}", routingId, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateApDisconnectedStatus(String apId, Equipment ce) {
|
||||
LOG.info("updateApDisconnectedStatus disconnected AP {}", apId);
|
||||
@@ -1162,6 +1122,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
return;
|
||||
}
|
||||
|
||||
ApElementConfiguration apElementConfig = (ApElementConfiguration) apNode.getDetails();
|
||||
|
||||
ProfileContainer profileContainer = new ProfileContainer(profileServiceInterface.getProfileWithChildren(apNode.getProfileId()));
|
||||
RfConfiguration rfConfig = (RfConfiguration) profileContainer.getChildOfTypeOrNull(apNode.getProfileId(), ProfileType.rf).getDetails();
|
||||
|
||||
for (OpensyncAPVIFState vifState : vifStateTables) {
|
||||
|
||||
LOG.debug("Processing vifState for interface {} on AP {}", vifState.getIfName(), apId);
|
||||
@@ -1192,10 +1157,19 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
vifState.getAssociatedClients(), channel);
|
||||
|
||||
RadioType radioType = null;
|
||||
if (channel <= MAX_ALLOWED_2GHz_CHANNEL_NUMBER) {
|
||||
radioType = RadioType.is2dot4GHz;
|
||||
} else {
|
||||
radioType = RadioType.is5GHz; // 8300 isn't supported
|
||||
Map<RadioType, RfElementConfiguration> rfElementMap = rfConfig.getRfConfigMap();
|
||||
Map<RadioType, ElementRadioConfiguration> elementRadioMap = apElementConfig.getRadioMap();
|
||||
|
||||
if (apElementConfig.getAdvancedRadioMap().isEmpty()) {
|
||||
LOG.warn("No AdvancedRadioMap for ap {} {}", apId, apElementConfig);
|
||||
continue;
|
||||
}
|
||||
for (RadioType rType : elementRadioMap.keySet()) {
|
||||
boolean autoChannelSelection = rfElementMap.get(rType).getAutoChannelSelection();
|
||||
if (elementRadioMap.get(rType).getActiveChannel(autoChannelSelection) == channel) {
|
||||
radioType = rType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
updateActiveBssids(customerId, equipmentId, apId, ssid, radioType, bssid, numClients);
|
||||
@@ -1486,10 +1460,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
if (currentActiveBSSIDs == null) {
|
||||
currentActiveBSSIDs = new ArrayList<>();
|
||||
} else {
|
||||
currentActiveBSSIDs = currentActiveBSSIDs.stream()
|
||||
.filter(p -> (p.getRadioType() != null && p.getSsid() != null))
|
||||
.filter(p -> !(p.getRadioType().equals(freqBand) && p.getSsid().equals(ssid)) )
|
||||
.collect(Collectors.toList());
|
||||
currentActiveBSSIDs = currentActiveBSSIDs.stream().filter(p -> (p.getRadioType() != null && p.getSsid() != null))
|
||||
.filter(p -> !p.getRadioType().equals(freqBand) || !p.getSsid().equals(ssid)).collect(Collectors.toList());
|
||||
LOG.debug("Processing Wifi_VIF_State table update for AP {}, activeBSSIDs bssidList without current radio freq {} and ssid {}", apId,
|
||||
currentActiveBSSIDs, ssid);
|
||||
}
|
||||
@@ -1826,7 +1798,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
clientSession.setLocationId(ce.getLocationId());
|
||||
clientSession.setDetails(new ClientSessionDetails());
|
||||
long derivedSessionId = WiFiSessionUtility.encodeWiFiAssociationId(timestamp / 1000, clientInstance.getMacAddress().getAddressAsLong());
|
||||
clientSession.getDetails().setSessionId(DERIVED_SESSION_ID_PREFIX + Long.toUnsignedString(derivedSessionId));
|
||||
clientSession.getDetails().setSessionId(Long.toUnsignedString(derivedSessionId));
|
||||
clientSession.getDetails().setDhcpDetails(new ClientDhcpDetails(Long.toUnsignedString(derivedSessionId)));
|
||||
clientSession.getDetails().setAssociationState(AssociationState._802_11_Associated);
|
||||
clientSession.getDetails().setIsReassociation(false);
|
||||
@@ -2275,13 +2247,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
Client client = clientServiceInterface.getOrNull(customerId, clientMacAddress);
|
||||
if (client == null) {
|
||||
LOG.info("Cannot find client instance for {}", clientMacAddress);
|
||||
ClientSession clientSession = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress);
|
||||
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);
|
||||
LOG.info("Session {} for client {} is now disconnected.", clientSession, clientSession.getMacAddress());
|
||||
}
|
||||
ClientSession session = clientServiceInterface.getSessionOrNull(customerId, equipmentId, clientMacAddress);
|
||||
if (session != null) {
|
||||
LOG.info("Delete clientSession for client that was removed from the Dhcp_Leased_IP table {}",
|
||||
clientServiceInterface.deleteSession(customerId, equipmentId, clientMacAddress));
|
||||
}
|
||||
} else if (clientMacAddress.equals(equipmentServiceInterface.get(equipmentId).getBaseMacAddress())) {
|
||||
LOG.info("Not a client device {} ", dhcpLeasedIps);
|
||||
@@ -2463,83 +2432,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
// TODO: will handle changes from Command_State table
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConfigVersionFromStatus(String apId) {
|
||||
long ret = 0;
|
||||
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||
|
||||
if (ovsdbSession == null) {
|
||||
LOG.debug("getConfigVersionFromStatus::Cannot get Session for AP {}", apId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long equipmentId = ovsdbSession.getEquipmentId();
|
||||
Equipment ce = equipmentServiceInterface.getOrNull(equipmentId);
|
||||
if (ce == null) {
|
||||
LOG.debug("getConfigVersionFromStatus Cannot get customer Equipment for {}", apId);
|
||||
return ret;
|
||||
}
|
||||
int customerId = ce.getCustomerId();
|
||||
if ((customerId < 0) || (equipmentId < 0)) {
|
||||
LOG.debug("getConfigVersionFromStatus::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
|
||||
if(protocolStatus != null) {
|
||||
EquipmentProtocolStatusData epsd = (EquipmentProtocolStatusData) protocolStatus.getDetails();
|
||||
if(epsd!=null && epsd.getReportedCfgDataVersion()!=null) {
|
||||
ret = epsd.getReportedCfgDataVersion();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigVersionInStatus(String apId, long configVersionFromProfiles) {
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||
|
||||
if (ovsdbSession == null) {
|
||||
LOG.debug("updateConfigVersionInStatus::Cannot get Session for AP {}", apId);
|
||||
return;
|
||||
}
|
||||
|
||||
long equipmentId = ovsdbSession.getEquipmentId();
|
||||
Equipment ce = equipmentServiceInterface.getOrNull(equipmentId);
|
||||
if (ce == null) {
|
||||
LOG.debug("updateConfigVersionInStatus Cannot get customer Equipment for {}", apId);
|
||||
return;
|
||||
}
|
||||
int customerId = ce.getCustomerId();
|
||||
if ((customerId < 0) || (equipmentId < 0)) {
|
||||
LOG.debug("updateConfigVersionInStatus::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId);
|
||||
return;
|
||||
}
|
||||
|
||||
Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
|
||||
if(protocolStatus == null) {
|
||||
protocolStatus = new Status();
|
||||
protocolStatus.setCustomerId(customerId);
|
||||
protocolStatus.setEquipmentId(equipmentId);
|
||||
protocolStatus.setCreatedTimestamp(System.currentTimeMillis());
|
||||
protocolStatus.setLastModifiedTimestamp(protocolStatus.getCreatedTimestamp());
|
||||
protocolStatus.setDetails(new EquipmentProtocolStatusData());
|
||||
}
|
||||
|
||||
EquipmentProtocolStatusData epsd = (EquipmentProtocolStatusData) protocolStatus.getDetails();
|
||||
if(epsd==null) {
|
||||
epsd = new EquipmentProtocolStatusData();
|
||||
protocolStatus.setDetails(epsd);
|
||||
}
|
||||
|
||||
epsd.setReportedCfgDataVersion(configVersionFromProfiles);
|
||||
|
||||
statusServiceInterface.update(protocolStatus);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the EquipmentStatus for this AP, and set all client sessions to
|
||||
* disconnected. Done as part of a reconfiguration/configuration change
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||
import com.telecominfraproject.wlan.client.session.models.ClientSessionDetails;
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationCloud;
|
||||
import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUtility;
|
||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
|
||||
|
||||
@@ -106,10 +105,10 @@ public class AsyncPublishService {
|
||||
processClientAssocEvent(customerId, equipmentId, locationId, apEventClientSession);
|
||||
}
|
||||
if (apEventClientSession.hasClientIpEvent()) {
|
||||
processClientIpEvent(apId, customerId, equipmentId, locationId, apEventClientSession);
|
||||
processClientIpEvent(customerId, equipmentId, locationId, apEventClientSession);
|
||||
}
|
||||
if (apEventClientSession.hasClientDisconnectEvent()) {
|
||||
processClientDisconnectEvent(apId, customerId, equipmentId, locationId, apEventClientSession);
|
||||
processClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession);
|
||||
}
|
||||
}
|
||||
realtimeEventPublisher.publishChannelHopEvents(customerId, equipmentId, locationId, eventReport);
|
||||
@@ -153,9 +152,6 @@ public class AsyncPublishService {
|
||||
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
|
||||
clientSession.getDetails().setRadioType(OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(apClientEvent.getBand()));
|
||||
clientSession.getDetails().setSsid(apClientEvent.getSsid());
|
||||
if (apClientEvent.hasBssid()) {
|
||||
clientSession.getDetails().setBssid(MacAddress.valueOf(apClientEvent.getBssid()));
|
||||
}
|
||||
if (apClientEvent.hasAuthStatus()) {
|
||||
clientSession.getDetails().setAssociationStatus(apClientEvent.getAuthStatus());
|
||||
}
|
||||
@@ -206,9 +202,6 @@ public class AsyncPublishService {
|
||||
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
|
||||
clientSession.getDetails().setRadioType(OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(apClientEvent.getBand()));
|
||||
clientSession.getDetails().setSsid(apClientEvent.getSsid());
|
||||
if (apClientEvent.hasBssid()) {
|
||||
clientSession.getDetails().setBssid(MacAddress.valueOf(apClientEvent.getBssid()));
|
||||
}
|
||||
if (apClientEvent.hasStatus()) {
|
||||
clientSession.getDetails().setAssociationStatus(apClientEvent.getStatus());
|
||||
}
|
||||
@@ -239,7 +232,7 @@ public class AsyncPublishService {
|
||||
|
||||
}
|
||||
|
||||
private void processClientIpEvent(String apId, int customerId, long equipmentId, long locationId, sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
|
||||
private void processClientIpEvent(int customerId, long equipmentId, long locationId, sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
|
||||
ClientIpEvent apClientEvent = apEventClientSession.getClientIpEvent();
|
||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, MacAddress.valueOf(apClientEvent.getStaMac()));
|
||||
if (client == null) {
|
||||
@@ -264,16 +257,12 @@ public class AsyncPublishService {
|
||||
if (clientSession.getDetails().getPriorEquipmentId() == null) {
|
||||
clientSession.getDetails().setPriorEquipmentId(clientSession.getEquipmentId());
|
||||
}
|
||||
|
||||
String sessionId = clientSession.getDetails().getSessionId();
|
||||
if (!Objects.equal(sessionId, Long.toUnsignedString(apEventClientSession.getSessionId()))) {
|
||||
if (sessionId != null && !sessionId.startsWith(OpensyncExternalIntegrationCloud.DERIVED_SESSION_ID_PREFIX)) {
|
||||
LOG.info("Ignored clientIpEvent for different session ID for AP {}, clientMac {}: currentSessionId {}, ipSessionID {} ", apId,
|
||||
apClientEvent.getStaMac(), sessionId, apEventClientSession.getSessionId());
|
||||
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, locationId, apEventClientSession.getClientIpEvent());
|
||||
return;
|
||||
}
|
||||
clientSession.getDetails().setPriorSessionId(sessionId);
|
||||
if (clientSession.getDetails().getPriorSessionId() == null) {
|
||||
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId())))
|
||||
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
|
||||
}
|
||||
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId()))) {
|
||||
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
|
||||
}
|
||||
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
|
||||
if (apClientEvent.hasIpAddr()) {
|
||||
@@ -299,7 +288,7 @@ public class AsyncPublishService {
|
||||
realtimeEventPublisher.publishClientIpEvent(customerId, equipmentId, locationId, apEventClientSession.getClientIpEvent());
|
||||
}
|
||||
|
||||
private void processClientDisconnectEvent(String apId, int customerId, long equipmentId, long locationId,
|
||||
private void processClientDisconnectEvent(int customerId, long equipmentId, long locationId,
|
||||
sts.OpensyncStats.EventReport.ClientSession apEventClientSession) {
|
||||
ClientDisconnectEvent apClientEvent = apEventClientSession.getClientDisconnectEvent();
|
||||
com.telecominfraproject.wlan.client.models.Client client = clientServiceInterface.getOrNull(customerId, MacAddress.valueOf(apClientEvent.getStaMac()));
|
||||
@@ -321,22 +310,16 @@ public class AsyncPublishService {
|
||||
clientSession.getDetails().setDhcpDetails(new ClientDhcpDetails(Long.toUnsignedString(apEventClientSession.getSessionId())));
|
||||
}
|
||||
|
||||
String sessionId = clientSession.getDetails().getSessionId();
|
||||
if (!Objects.equal(sessionId, Long.toUnsignedString(apEventClientSession.getSessionId()))) {
|
||||
if (sessionId != null && !sessionId.startsWith(OpensyncExternalIntegrationCloud.DERIVED_SESSION_ID_PREFIX)) {
|
||||
LOG.info("Ignored clientDisconnectEvent for different session ID for AP {}, clientMac {}: currentSessionId {}, disconnectSessionID {} ", apId,
|
||||
apClientEvent.getStaMac(), sessionId, apEventClientSession.getSessionId());
|
||||
realtimeEventPublisher.publishClientDisconnectEvent(customerId, equipmentId, locationId, apEventClientSession.getClientDisconnectEvent());
|
||||
return;
|
||||
}
|
||||
clientSession.getDetails().setPriorSessionId(sessionId);
|
||||
if (clientSession.getDetails().getPriorSessionId() == null) {
|
||||
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId())))
|
||||
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
|
||||
}
|
||||
if (!Objects.equal(clientSession.getDetails().getSessionId(), Long.toUnsignedString(apEventClientSession.getSessionId()))) {
|
||||
clientSession.getDetails().setPriorSessionId(clientSession.getDetails().getSessionId());
|
||||
}
|
||||
clientSession.getDetails().setSessionId(Long.toUnsignedString(apEventClientSession.getSessionId()));
|
||||
clientSession.getDetails().setRadioType(OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(apClientEvent.getBand()));
|
||||
clientSession.getDetails().setSsid(apClientEvent.getSsid());
|
||||
if (apClientEvent.hasBssid()) {
|
||||
clientSession.getDetails().setBssid(MacAddress.valueOf(apClientEvent.getBssid()));
|
||||
}
|
||||
if (apClientEvent.hasDevType()) {
|
||||
if (apClientEvent.getDevType().equals(DeviceType.DEV_AP)) {
|
||||
clientSession.getDetails().setDisconnectByApTimestamp(apClientEvent.getTimestampMs());
|
||||
|
||||
@@ -520,18 +520,15 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
|
||||
if (apNodeMetrics.getSourceTimestampMs() < survey.getTimestampMs())
|
||||
apNodeMetrics.setSourceTimestampMs(survey.getTimestampMs());
|
||||
|
||||
float pctBusyTx = (float)busyTx / totalDurationMs;
|
||||
int pctBusyTx = busyTx / totalDurationMs;
|
||||
checkIfOutOfBound("pctBusyTx", pctBusyTx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
radioUtil.setAssocClientTx(Math.round(pctBusyTx));
|
||||
|
||||
float pctBusyRx = (float) busyRx / totalDurationMs;
|
||||
checkIfOutOfBound("pctBusyRx", pctBusyRx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
|
||||
float pctBusySelf = (float) busySelf / totalDurationMs;
|
||||
checkIfOutOfBound("pctBusySelf", pctBusySelf, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
radioUtil.setAssocClientRx(Math.round(pctBusySelf));
|
||||
|
||||
double pctIBSS = (double) (busyTx + busySelf) / totalDurationMs;
|
||||
radioUtil.setAssocClientTx(pctBusyTx);
|
||||
int pctBusyRx = busyRx / totalDurationMs;
|
||||
checkIfOutOfBound("pctBusyRx", pctBusyRx, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
radioUtil.setAssocClientRx(pctBusyRx);
|
||||
|
||||
double pctIBSS = (busyTx + busySelf) / totalDurationMs;
|
||||
if (pctIBSS > 100D || pctIBSS < 0D) {
|
||||
LOG.warn(
|
||||
"Calculated value for {} {} is out of bounds on totalDurationMs {} for survey.getBand {}. busyTx {} busyRx {} busy {} busySelf {} "
|
||||
@@ -541,13 +538,13 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
|
||||
}
|
||||
radioUtil.setIbss(pctIBSS);
|
||||
|
||||
float nonWifi = (float) (busy - (busyTx + busyRx)) / totalDurationMs;
|
||||
int nonWifi = (busy - (busyTx + busyRx)) / totalDurationMs;
|
||||
checkIfOutOfBound("nonWifi", nonWifi, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
radioUtil.setNonWifi(Math.round(nonWifi));
|
||||
radioUtil.setNonWifi(nonWifi);
|
||||
|
||||
float pctOBSSAndSelfErrors = (float) (busyRx - busySelf) / totalDurationMs;
|
||||
int pctOBSSAndSelfErrors = (busyRx - busySelf) / totalDurationMs;
|
||||
checkIfOutOfBound("OBSSAndSelfErrors", pctOBSSAndSelfErrors, survey, totalDurationMs, busyTx, busyRx, busy, busySelf);
|
||||
radioUtil.setUnassocClientRx(Math.round(pctOBSSAndSelfErrors));
|
||||
radioUtil.setUnassocClientRx(pctOBSSAndSelfErrors);
|
||||
|
||||
radioType = OvsdbToWlanCloudTypeMappingUtility.getRadioTypeFromOpensyncStatsRadioBandType(survey.getBand());
|
||||
if (radioType != RadioType.UNSUPPORTED) {
|
||||
@@ -562,7 +559,7 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
|
||||
}
|
||||
|
||||
Long totalUtilization = Math.round((double) busy / totalDurationMs);
|
||||
Long totalNonWifi = Math.round((double) (busy - (busyTx + busyRx)) / totalDurationMs);
|
||||
Long totalNonWifi = totalUtilization - ((busyTx + busyRx) / totalDurationMs);
|
||||
|
||||
EquipmentCapacityDetails cap = new EquipmentCapacityDetails();
|
||||
cap.setUnavailableCapacity(totalNonWifi.intValue());
|
||||
@@ -626,8 +623,8 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
|
||||
alarm = alarmServiceInterface.create(alarm);
|
||||
}
|
||||
|
||||
private void checkIfOutOfBound(String checkedType, float checkedValue, Survey survey, int totalDurationMs, int busyTx, int busyRx, int busy, int busySelf) {
|
||||
if (checkedValue > 100F || checkedValue < 0F) {
|
||||
private void checkIfOutOfBound(String checkedType, int checkedValue, Survey survey, int totalDurationMs, int busyTx, int busyRx, int busy, int busySelf) {
|
||||
if (checkedValue > 100 || checkedValue < 0) {
|
||||
LOG.warn(
|
||||
"Calculated value for {} {} is out of bounds on totalDurationMs {} for survey.getBand {}. busyTx {} busyRx {} busy {} busySelf {} "
|
||||
+ " survey.getTimestampMs {}, survey.getSurveyListList {}",
|
||||
@@ -1190,12 +1187,12 @@ public class MqttStatsPublisher implements StatsPublisherInterface {
|
||||
}
|
||||
|
||||
String[] parts = topic.split("/");
|
||||
if (parts.length < 4) {
|
||||
if (parts.length < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// apId is the third element in the topic
|
||||
return parts[3];
|
||||
return parts[2];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -394,7 +394,7 @@ public class OpensyncExternalIntegrationCloudTest {
|
||||
|
||||
@Test
|
||||
public void testApDisconnected() {
|
||||
opensyncExternalIntegrationCloud.apDisconnected("Test_Client_21P10C68818122", 0L);
|
||||
opensyncExternalIntegrationCloud.apDisconnected("Test_Client_21P10C68818122");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,11 +22,7 @@ public interface OpensyncExternalIntegrationInterface {
|
||||
INIT, INSERT, DELETE, MODIFY
|
||||
}
|
||||
|
||||
void apDisconnected(String apId, Long ctxRoutingId);
|
||||
|
||||
Long getLatestRoutingId(String apId);
|
||||
|
||||
void removeRoutingRecord(Long routingId);
|
||||
void apDisconnected(String apId);
|
||||
|
||||
OpensyncAPConfig getApConfig(String apId);
|
||||
|
||||
@@ -60,8 +56,4 @@ public interface OpensyncExternalIntegrationInterface {
|
||||
void clearEquipmentStatus(String apId);
|
||||
|
||||
void processMqttMessage(String topic, Report report);
|
||||
|
||||
long getConfigVersionFromStatus(String apId);
|
||||
|
||||
void updateConfigVersionInStatus(String apId, long configVersionFromProfiles);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
public class OvsdbSession {
|
||||
@@ -9,7 +7,6 @@ public class OvsdbSession {
|
||||
private String apId;
|
||||
private long routingId;
|
||||
private long equipmentId;
|
||||
private AtomicInteger currentConfigNumInFlight = new AtomicInteger();
|
||||
|
||||
public OvsdbClient getOvsdbClient() {
|
||||
return ovsdbClient;
|
||||
@@ -35,9 +32,5 @@ public class OvsdbSession {
|
||||
public void setEquipmentId(long equipmentId) {
|
||||
this.equipmentId = equipmentId;
|
||||
}
|
||||
|
||||
public AtomicInteger getCurrentConfigNumInFlight() {
|
||||
return currentConfigNumInFlight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import java.util.Objects;
|
||||
|
||||
public class ConnectNodeInfo implements Cloneable {
|
||||
|
||||
public static String CONFIG_VERSION_PROPERTY_NAME = "tip/reportedCfgDataVersion";
|
||||
|
||||
public Map<String, String> mqttSettings = new HashMap<>();
|
||||
public Map<String, String> versionMatrix = new HashMap<>();
|
||||
public Map<String, String> wifiRadioStates = new HashMap<>();
|
||||
@@ -37,18 +35,6 @@ public class ConnectNodeInfo implements Cloneable {
|
||||
public String manufacturerDate;
|
||||
public String certificationRegion;
|
||||
|
||||
public long getConfigVersion() {
|
||||
|
||||
long ret = 0;
|
||||
try {
|
||||
ret = Long.parseLong(versionMatrix.get(CONFIG_VERSION_PROPERTY_NAME));
|
||||
} catch(Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectNodeInfo clone() {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -45,67 +44,9 @@ public class OpensyncAPConfig extends OpensyncAPBase {
|
||||
private EquipmentGatewayRecord equipmentGateway;
|
||||
private List<Profile> captiveProfiles;
|
||||
private List<Profile> bonjourGatewayProfiles;
|
||||
|
||||
private long configVersion;
|
||||
|
||||
private List<MacAddress> blockedClients;
|
||||
|
||||
public long getConfigVersion() {
|
||||
//go through all child objects and get the most recent lastModifiedTimestamp from them
|
||||
configVersion = 0;
|
||||
|
||||
if(customerEquipment!=null && customerEquipment.getLastModifiedTimestamp()> configVersion) {
|
||||
configVersion = customerEquipment.getLastModifiedTimestamp();
|
||||
}
|
||||
|
||||
if(hotspotConfig!=null) {
|
||||
configVersion = getLatestLastMod(configVersion, hotspotConfig.getHotspot20OperatorSet());
|
||||
configVersion = getLatestLastMod(configVersion, hotspotConfig.getHotspot20ProfileSet());
|
||||
configVersion = getLatestLastMod(configVersion, hotspotConfig.getHotspot20ProviderSet());
|
||||
configVersion = getLatestLastMod(configVersion, hotspotConfig.getHotspot20VenueSet());
|
||||
}
|
||||
|
||||
configVersion = getLatestLastMod(configVersion, apProfile);
|
||||
configVersion = getLatestLastMod(configVersion, rfProfile);
|
||||
configVersion = getLatestLastMod(configVersion, ssidProfile);
|
||||
configVersion = getLatestLastMod(configVersion, metricsProfile);
|
||||
configVersion = getLatestLastMod(configVersion, radiusProfiles);
|
||||
configVersion = getLatestLastMod(configVersion, wiredEthernetPortProfile);
|
||||
|
||||
if(equipmentLocation!=null && equipmentLocation.getLastModifiedTimestamp()> configVersion) {
|
||||
configVersion = equipmentLocation.getLastModifiedTimestamp();
|
||||
}
|
||||
|
||||
configVersion = getLatestLastMod(configVersion, captiveProfiles);
|
||||
configVersion = getLatestLastMod(configVersion, bonjourGatewayProfiles);
|
||||
|
||||
return configVersion;
|
||||
}
|
||||
|
||||
private long getLatestLastMod(long incomingLastMod, Collection<Profile> profiles) {
|
||||
|
||||
if(profiles!=null) {
|
||||
for(Profile p: profiles) {
|
||||
if(incomingLastMod < p.getLastModifiedTimestamp()) {
|
||||
incomingLastMod = p.getLastModifiedTimestamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return incomingLastMod;
|
||||
}
|
||||
|
||||
private long getLatestLastMod(long incomingLastMod, Profile profile) {
|
||||
|
||||
if(profile!=null) {
|
||||
if(incomingLastMod < profile.getLastModifiedTimestamp()) {
|
||||
incomingLastMod = profile.getLastModifiedTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
return incomingLastMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpensyncAPConfig clone() {
|
||||
OpensyncAPConfig ret = (OpensyncAPConfig) super.clone();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegr
|
||||
LOG.info("ConnectNodeInfo {}", connectNodeInfo);
|
||||
}
|
||||
|
||||
public void apDisconnected(String apId, Long ctxRoutingId) {
|
||||
public void apDisconnected(String apId) {
|
||||
LOG.info("AP {} got disconnected from the gateway", apId);
|
||||
}
|
||||
|
||||
@@ -212,25 +212,4 @@ public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegr
|
||||
LOG.info("nodeStateDbTableUpdate for AP {}", apId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConfigVersionFromStatus(String inventoryId) {
|
||||
//0 means always push config to ap, do not do the version check for the configuration before pushing it
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfigVersionInStatus(String apId, long configVersionFromProfiles) {
|
||||
// do nothing here
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLatestRoutingId(String apId) {
|
||||
LOG.info("getLatestRoutingId for AP {}", apId);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoutingRecord(Long routingId) {
|
||||
LOG.info("removeRoutingRecord for routingId {}", routingId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,6 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
|
||||
@Autowired
|
||||
private OpensyncExternalIntegrationInterface opensyncExternalIntegrationInterface;
|
||||
|
||||
@Value("${tip.wlan.internalHostName:localhost}")
|
||||
private String internalHostName;
|
||||
|
||||
// dtop: use anonymous constructor to ensure that the following code always
|
||||
// get executed,
|
||||
// even when somebody adds another constructor in here
|
||||
@@ -141,7 +138,7 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
|
||||
MQTT mqtt = new MQTT();
|
||||
mqtt.setHost("tls://" + mqttBrokerAddress + ":" + mqttBrokerListenPort);
|
||||
LOG.info("Connecting to MQTT broker at {}", mqtt.getHost());
|
||||
mqtt.setClientId("opensync_mqtt_" + internalHostName);
|
||||
mqtt.setClientId("opensync_mqtt");
|
||||
mqtt.setUserName(username);
|
||||
mqtt.setPassword(password);
|
||||
blockingConnection = mqtt.blockingConnection();
|
||||
@@ -150,7 +147,7 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
|
||||
LOG.debug("Connected to MQTT broker at {}", mqtt.getHost());
|
||||
|
||||
// NB. setting to AT_MOST_ONCE to match the APs message level
|
||||
Topic[] topics = {new Topic("/ap/opensync_mqtt_" + internalHostName + "/#", QoS.AT_MOST_ONCE),};
|
||||
Topic[] topics = {new Topic("/ap/#", QoS.AT_MOST_ONCE),};
|
||||
|
||||
blockingConnection.subscribe(topics);
|
||||
LOG.info("Subscribed to mqtt topics {}", Arrays.asList(topics));
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.telecominfraproject.wlan.opensync.external.integration.models.*;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.metrics.OvsdbClientWithMetrics;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.metrics.OvsdbMetrics;
|
||||
import com.telecominfraproject.wlan.opensync.util.OvsdbClientUtil;
|
||||
import com.telecominfraproject.wlan.opensync.util.OvsdbStringConstants;
|
||||
import com.telecominfraproject.wlan.opensync.util.SslUtil;
|
||||
import com.vmware.ovsdb.callback.ConnectionCallback;
|
||||
@@ -73,12 +72,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.defaultCommandDurationSec:3600}")
|
||||
private long defaultCommandDurationSec;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.checkConfigVersionFromStatus:true}")
|
||||
private boolean checkBeforePushConfigVersionFromStatus;
|
||||
|
||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.checkConfigVersionFromAp:true}")
|
||||
private boolean checkBeforePushConfigVersionFromAp;
|
||||
|
||||
@Autowired
|
||||
private SslContext sslContext;
|
||||
|
||||
@@ -142,32 +135,26 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
subjectDn = ((X509Certificate) remoteCertificate).getSubjectDN().getName();
|
||||
|
||||
String clientCn = SslUtil.extractCN(subjectDn);
|
||||
if (clientCn != null && !clientCn.isEmpty()) {
|
||||
LOG.info("ovsdbClient connecting from {} on port {} clientCn {}", remoteHost, localPort, clientCn);
|
||||
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
|
||||
// successfully connected - register it in our
|
||||
// connectedClients table
|
||||
|
||||
String key = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.newSession(key, ovsdbClient);
|
||||
extIntegrationInterface.apConnected(key, connectNodeInfo);
|
||||
// DT: at this point the routing Id is associated with the session, let's store it into the
|
||||
// connectionInfo object so that the disconnect handler has access to it
|
||||
OvsdbClientUtil.setRoutingId(ovsdbClient, ovsdbSession.getRoutingId());
|
||||
|
||||
processConnectRequest(ovsdbClient, clientCn, connectNodeInfo);
|
||||
|
||||
monitorOvsdbStateTables(ovsdbClient, key);
|
||||
|
||||
connectionsCreated.increment();
|
||||
LOG.info("ovsdbClient connected from {} on port {} AP {} ", remoteHost, localPort, key);
|
||||
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
|
||||
} else {
|
||||
LOG.debug("ovsdbClient: clientCn is empty - not connecting.");
|
||||
}
|
||||
|
||||
LOG.info("ovsdbClient connecting from {} on port {} clientCn {}", remoteHost, localPort, clientCn);
|
||||
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
|
||||
// successfully connected - register it in our
|
||||
// connectedClients table
|
||||
|
||||
String key = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
||||
ovsdbSessionMapInterface.newSession(key, ovsdbClient);
|
||||
|
||||
extIntegrationInterface.apConnected(key, connectNodeInfo);
|
||||
|
||||
processConnectRequest(ovsdbClient, clientCn, connectNodeInfo);
|
||||
|
||||
monitorOvsdbStateTables(ovsdbClient, key);
|
||||
|
||||
connectionsCreated.increment();
|
||||
LOG.info("ovsdbClient connected from {} on port {} AP {} ", remoteHost, localPort, key);
|
||||
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
|
||||
|
||||
} catch (IllegalStateException e) {
|
||||
connectionsFailed.increment();
|
||||
LOG.error("autoprovisioning error {}", e.getMessage(), e);
|
||||
@@ -188,7 +175,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
connectionsDropped.increment();
|
||||
|
||||
String remoteHost;
|
||||
int remotePort;
|
||||
int localPort;
|
||||
String clientCn;
|
||||
|
||||
@@ -204,7 +190,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
|
||||
try {
|
||||
remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
|
||||
remotePort = ovsdbClient.getConnectionInfo().getRemotePort();
|
||||
localPort = ovsdbClient.getConnectionInfo().getLocalPort();
|
||||
String subjectDn = null;
|
||||
try {
|
||||
@@ -215,63 +200,17 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
// do nothing
|
||||
}
|
||||
clientCn = SslUtil.extractCN(subjectDn);
|
||||
if (clientCn != null && !clientCn.isEmpty()) {
|
||||
Long ctxRoutingId = OvsdbClientUtil.getRoutingId(ovsdbClient);
|
||||
Long latestDbRoutingId = extIntegrationInterface.getLatestRoutingId(clientCn);
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(clientCn);
|
||||
|
||||
LOG.info("Determine true disconnect with AP {} ctxRoutingId {} latestDbRoutingId {} ", clientCn, ctxRoutingId, latestDbRoutingId);
|
||||
// Determine whether this is a true disconnect based on latest routing record
|
||||
if (ctxRoutingId != null && latestDbRoutingId != null) {
|
||||
// if context matches latest DB routingId, this is a true disconnect
|
||||
if (ctxRoutingId.equals(latestDbRoutingId)) {
|
||||
try {
|
||||
extIntegrationInterface.apDisconnected(clientCn, ctxRoutingId);
|
||||
ovsdbSessionMapInterface.removeSession(clientCn);
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Unable to process ap disconnect. {}", e);
|
||||
}
|
||||
} else {
|
||||
if (ovsdbSession != null) {
|
||||
if (!latestDbRoutingId.equals(ovsdbSession.getRoutingId())) {
|
||||
ovsdbSessionMapInterface.removeSession(clientCn);
|
||||
}
|
||||
}
|
||||
|
||||
extIntegrationInterface.removeRoutingRecord(ctxRoutingId);
|
||||
}
|
||||
|
||||
// else, clearly handle all other cases
|
||||
} else if (ctxRoutingId == null && latestDbRoutingId != null) {
|
||||
// session was not initialized properly in connect path, we can remove this session
|
||||
LOG.debug("ctxRoutingId null latestDbRoutingId {}, remove non-initialized session for AP {} ", latestDbRoutingId, clientCn);
|
||||
if (ovsdbSession != null) {
|
||||
if (ovsdbSession.getRoutingId() == 0L) {
|
||||
ovsdbSessionMapInterface.removeSession(clientCn);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ctxRoutingId != null && latestDbRoutingId == null) {
|
||||
// no routing exist at all, so we know this session is not using any routing record, we can remove this session
|
||||
LOG.debug("ctxRoutingId {} latestDbRoutingId null, no routing exists, remove session for AP {} ", latestDbRoutingId, clientCn);
|
||||
if (ovsdbSession != null) {
|
||||
if (ctxRoutingId.equals(ovsdbSession.getRoutingId())) {
|
||||
ovsdbSessionMapInterface.removeSession(clientCn);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// ctxRoutingId == null && latestDbRoutingId == null
|
||||
// This session is not initialized properly and no routings exist for any session
|
||||
// We can remove this session without any checks
|
||||
LOG.debug("ctxRoutingId null latestDbRoutingId null, remove session for AP {} ", latestDbRoutingId, clientCn);
|
||||
ovsdbSessionMapInterface.removeSession(clientCn);
|
||||
key = ovsdbSessionMapInterface.lookupClientId(ovsdbClient);
|
||||
if (key != null) {
|
||||
try {
|
||||
extIntegrationInterface.apDisconnected(key);
|
||||
ovsdbSessionMapInterface.removeSession(key);
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Unable to process ap disconnect. {}", e);
|
||||
}
|
||||
|
||||
LOG.info("ovsdbClient disconnected from {} on local port {} remote port {} clientCn {} ", remoteHost, localPort,
|
||||
remotePort, clientCn);
|
||||
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
|
||||
}
|
||||
LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} AP {} ", remoteHost, localPort, clientCn, key);
|
||||
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
|
||||
} finally {
|
||||
try {
|
||||
ovsdbClient.shutdown();
|
||||
@@ -303,69 +242,15 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
|
||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||
|
||||
//get last known configVersion from the AP
|
||||
long configVersionFromAp = checkBeforePushConfigVersionFromAp ? connectNodeInfo.getConfigVersion() : 0;
|
||||
|
||||
//get last known configVersion from the EquipmentProtocolStatusData
|
||||
long configVersionFromStatus = checkBeforePushConfigVersionFromStatus ? extIntegrationInterface.getConfigVersionFromStatus(apId) : 0;
|
||||
|
||||
//get current configVersion from the profiles and equipment
|
||||
long configVersionFromProfiles = opensyncAPConfig.getConfigVersion();
|
||||
|
||||
boolean needToPushConfigToAP = needToPushToAp(configVersionFromAp, configVersionFromStatus, configVersionFromProfiles);
|
||||
|
||||
if(needToPushConfigToAP) {
|
||||
pushConfigToAp(ovsdbClient, opensyncAPConfig, apId, configVersionFromProfiles);
|
||||
}
|
||||
|
||||
LOG.debug("Client connect Done");
|
||||
}
|
||||
|
||||
private boolean needToPushToAp(long configVersionFromAp, long configVersionFromStatus, long configVersionFromProfiles) {
|
||||
|
||||
boolean ret = false;
|
||||
|
||||
if(configVersionFromAp == 0) {
|
||||
LOG.debug("do not know what is on AP, let's push new config");
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if(checkBeforePushConfigVersionFromAp && configVersionFromAp < configVersionFromProfiles ) {
|
||||
LOG.debug("our profiles are more recent than what was pushed to AP previously, let's push new config");
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if(checkBeforePushConfigVersionFromStatus && configVersionFromStatus < configVersionFromProfiles) {
|
||||
LOG.debug("our profiles are more recent than the version stored in the protocol status, let's push new config");
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if(!checkBeforePushConfigVersionFromAp && !checkBeforePushConfigVersionFromStatus) {
|
||||
LOG.debug("we do not do any checks for config versions - let's push new config");
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if(!ret) {
|
||||
LOG.debug("no need to push new config to AP");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
private void pushConfigToAp(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig, String apInventoryId, long configVersionFromProfiles) {
|
||||
|
||||
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
||||
if(opensyncAPConfig!=null) {
|
||||
ovsdbDao.resetWiredPorts(ovsdbClient, opensyncAPConfig); // need to run this first before remove Status
|
||||
}
|
||||
ovsdbDao.resetWiredPorts(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||
ovsdbDao.removeRadsecRadiusAndRealmConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||
|
||||
extIntegrationInterface.clearEquipmentStatus(apInventoryId);
|
||||
extIntegrationInterface.clearEquipmentStatus(apId);
|
||||
|
||||
if (opensyncAPConfig != null) {
|
||||
ovsdbDao.configureNode(ovsdbClient, opensyncAPConfig);
|
||||
@@ -390,17 +275,12 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
ovsdbDao.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent);
|
||||
|
||||
} else {
|
||||
LOG.info("No Configuration available for {}", apInventoryId);
|
||||
LOG.info("No Configuration available for {}", apId);
|
||||
}
|
||||
|
||||
//after a successful config push let's update the configVersion on the AP and in the EquipmentProtocolStatusData
|
||||
if(checkBeforePushConfigVersionFromStatus) {
|
||||
extIntegrationInterface.updateConfigVersionInStatus(apInventoryId, configVersionFromProfiles);
|
||||
}
|
||||
ovsdbDao.updateConfigVersionInNode(ovsdbClient, configVersionFromProfiles);
|
||||
|
||||
LOG.debug("Client connect Done");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<String> getConnectedClientIds() {
|
||||
return ovsdbSessionMapInterface.getConnectedClientIds();
|
||||
@@ -440,56 +320,45 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
|
||||
OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient();
|
||||
|
||||
int currentConfigCount = ovsdbSession.getCurrentConfigNumInFlight().get();
|
||||
if (currentConfigCount == 0L) {
|
||||
// Current count is 0, start this config push
|
||||
// Increment other incoming configs into the count until this config push is done
|
||||
currentConfigCount = ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||
do {
|
||||
try {
|
||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||
|
||||
if (opensyncAPConfig == null) {
|
||||
LOG.warn("AP with id " + apId + " does not have a config to apply.");
|
||||
return;
|
||||
}
|
||||
|
||||
//get last known configVersion from the AP
|
||||
long configVersionFromAp = checkBeforePushConfigVersionFromAp ? ovsdbDao.getConfigVersionFromNode(ovsdbClient) : 0;
|
||||
|
||||
//get last known configVersion from the EquipmentProtocolStatusData
|
||||
long configVersionFromStatus = checkBeforePushConfigVersionFromStatus ? extIntegrationInterface.getConfigVersionFromStatus(apId) : 0;
|
||||
|
||||
//get current configVersion from the profiles and equipment
|
||||
long configVersionFromProfiles = opensyncAPConfig.getConfigVersion();
|
||||
|
||||
boolean needToPushConfigToAP = needToPushToAp(configVersionFromAp, configVersionFromStatus, configVersionFromProfiles);
|
||||
|
||||
if(needToPushConfigToAP) {
|
||||
pushConfigToAp(ovsdbClient, opensyncAPConfig, apId, configVersionFromProfiles);
|
||||
}
|
||||
LOG.debug("Finished processConfigChanged for {}", apId);
|
||||
} catch (Exception ex) {
|
||||
// If anything fails in the ovsdb config push, clean up count and exit
|
||||
ovsdbSession.getCurrentConfigNumInFlight().set(0);
|
||||
return;
|
||||
}
|
||||
int checkCount = ovsdbSession.getCurrentConfigNumInFlight().get();
|
||||
if (checkCount == currentConfigCount) {
|
||||
// Count didn't change from pre-config push, we can clean up and exit
|
||||
if (ovsdbSession.getCurrentConfigNumInFlight().compareAndSet(currentConfigCount, 0)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Count has changed, update the currentConfigCount and rerun config push
|
||||
ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||
}
|
||||
} while (ovsdbSession.getCurrentConfigNumInFlight().get() != 0);
|
||||
} else {
|
||||
// Count is not 0, another request is being processed for this OvsdbSession
|
||||
// Remember this request, and the other thread will check the count when it's done
|
||||
ovsdbSession.getCurrentConfigNumInFlight().incrementAndGet();
|
||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||
|
||||
if (opensyncAPConfig == null) {
|
||||
LOG.warn("AP with id " + apId + " does not have a config to apply.");
|
||||
return;
|
||||
}
|
||||
|
||||
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
||||
ovsdbDao.resetWiredPorts(ovsdbClient, opensyncAPConfig); // need to run this first before remove Status
|
||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||
ovsdbDao.removeRadsecRadiusAndRealmConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient);
|
||||
|
||||
extIntegrationInterface.clearEquipmentStatus(apId);
|
||||
|
||||
ovsdbDao.configureNode(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureWiredPort(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureRadsecRadiusAndRealm(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
||||
}
|
||||
|
||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||
|
||||
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
||||
}
|
||||
ovsdbDao.enableNetworkProbeForSyntheticClient(ovsdbClient);
|
||||
ovsdbDao.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent);
|
||||
|
||||
LOG.debug("Finished processConfigChanged for {}", apId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -596,12 +465,12 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
if (rowUpdate.getNew() == null) {
|
||||
// delete
|
||||
Map<String, String> rowMap = new HashMap<>();
|
||||
|
||||
rowUpdate.getOld().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||
|
||||
delete.add(rowMap);
|
||||
// delete
|
||||
} else if (rowUpdate.getOld() == null) {
|
||||
// insert
|
||||
Map<String, String> rowMap = new HashMap<>();
|
||||
@@ -610,13 +479,15 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
|
||||
insert.add(rowMap);
|
||||
} else {
|
||||
// update
|
||||
|
||||
// insert
|
||||
Map<String, String> rowMap = new HashMap<>();
|
||||
|
||||
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
|
||||
rowUpdate.getOld().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||
|
||||
update.add(rowMap);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,7 +511,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
|
||||
});
|
||||
|
||||
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(ovsdbDao.getInitialOpensyncDhcpLeasedIp(awCf.join(), key, ovsdbClient), key, RowUpdateOperation.INIT);
|
||||
awCf.join();
|
||||
|
||||
}
|
||||
|
||||
@@ -760,7 +631,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(ovsdbDao.getInitialOpensyncWifiAssociatedClients(acCf.join(), key, ovsdbClient), key);
|
||||
|
||||
}
|
||||
@@ -822,7 +693,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
|
||||
|
||||
CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
|
||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(false, true, true, true)))),
|
||||
tableUpdates -> {
|
||||
try {
|
||||
LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}", tableUpdates);
|
||||
@@ -860,19 +731,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
try {
|
||||
List<OpensyncAPVIFState> vifsToInsert = new ArrayList<>();
|
||||
TableUpdates initialTableUpdates = vsCf.join();
|
||||
for (TableUpdate tableUpdate : initialTableUpdates.getTableUpdates().values()) {
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
vifsToInsert.addAll(ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
||||
}
|
||||
}
|
||||
extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsert, key);
|
||||
} catch (Exception e) {
|
||||
LOG.error("initial wifiVIFStateDbTableUpdate failed", e);
|
||||
}
|
||||
vsCf.join();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -152,11 +152,6 @@ public class OvsdbDao extends OvsdbDaoBase {
|
||||
OvsdbClient ovsdbClient) {
|
||||
return ovsdbMonitor.getInitialOpensyncWifiAssociatedClients(join, key, ovsdbClient);
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getInitialOpensyncDhcpLeasedIp(TableUpdates join, String key,
|
||||
OvsdbClient ovsdbClient) {
|
||||
return ovsdbMonitor.getInitialOpensyncDhcpLeasedIp(join, key, ovsdbClient);
|
||||
}
|
||||
|
||||
public Collection<? extends OpensyncAPInetState> getOpensyncApInetStateForRowUpdate(RowUpdate rowUpdate, String key,
|
||||
OvsdbClient ovsdbClient) {
|
||||
@@ -264,12 +259,4 @@ public class OvsdbDao extends OvsdbDaoBase {
|
||||
ovsdbNodeConfig.configureDynamicRadiusProxyToAPC(ovsdbClient, opensyncAPConfig);
|
||||
}
|
||||
|
||||
public long getConfigVersionFromNode(OvsdbClient ovsdbClient) {
|
||||
return ovsdbNode.getConfigVersionFromNode(ovsdbClient);
|
||||
}
|
||||
|
||||
public void updateConfigVersionInNode(OvsdbClient ovsdbClient, long configVersionFromProfiles) {
|
||||
ovsdbNode.updateConfigVersionInNode(ovsdbClient, configVersionFromProfiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,33 +83,6 @@ public class OvsdbMonitor extends OvsdbDaoBase {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<Map<String, String>> getInitialOpensyncDhcpLeasedIp(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
LOG.debug("getInitialOpensyncDhcpLeasedIp:");
|
||||
List<Map<String, String>> ret = new ArrayList<>();
|
||||
try {
|
||||
LOG.debug(dhcpLeasedIpDbTable + "_" + apId + " initial monitor table state received {}",
|
||||
tableUpdates);
|
||||
|
||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
if (rowUpdate.getNew() != null) {
|
||||
|
||||
Map<String, String> rowMap = new HashMap<>();
|
||||
|
||||
rowUpdate.getNew().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||
|
||||
ret.add(rowMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw (e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<OpensyncAPInetState> getOpensyncApInetStateForRowUpdate(RowUpdate rowUpdate, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
@@ -32,10 +32,6 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@Component
|
||||
public class OvsdbNode extends OvsdbDaoBase {
|
||||
|
||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.internalHostName:localhost}")
|
||||
private String internalHostName;
|
||||
|
||||
String changeRedirectorAddress(OvsdbClient ovsdbClient, String apId, String newRedirectorAddress) {
|
||||
try {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
@@ -384,7 +380,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
Map<String, String> newMqttSettings = new HashMap<>();
|
||||
newMqttSettings.put("broker", mqttBrokerAddress);
|
||||
String mqttClientName = OvsdbToWlanCloudTypeMappingUtility.getAlteredClientCnIfRequired(clientCn, incomingConnectNodeInfo, preventCnAlteration);
|
||||
newMqttSettings.put("topics", "/ap/opensync_mqtt_" + internalHostName + "/" + mqttClientName + "/opensync");
|
||||
newMqttSettings.put("topics", "/ap/" + mqttClientName + "/opensync");
|
||||
newMqttSettings.put("port", "" + mqttBrokerExternalPort);
|
||||
newMqttSettings.put("compress", "zlib");
|
||||
newMqttSettings.put("qos", "0");
|
||||
@@ -421,96 +417,4 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public long getConfigVersionFromNode(OvsdbClient ovsdbClient) {
|
||||
|
||||
long ret = 0;
|
||||
|
||||
Map<String, String> versionMatrix = getVersionMatrixFromNode(ovsdbClient);
|
||||
|
||||
try {
|
||||
ret = Long.parseLong(versionMatrix.get(ConnectNodeInfo.CONFIG_VERSION_PROPERTY_NAME));
|
||||
} catch(Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
LOG.debug("getConfigVersionFromNode {}", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Map<String, String> getVersionMatrixFromNode(OvsdbClient ovsdbClient) {
|
||||
|
||||
Map<String, String> ret = new HashMap<>();
|
||||
|
||||
try {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
List<String> columns = new ArrayList<>();
|
||||
columns.add("version_matrix");
|
||||
columns.add("id");
|
||||
|
||||
operations.add(new Select(awlanNodeDbTable, conditions, columns));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Select from {}:", awlanNodeDbTable);
|
||||
|
||||
for (OperationResult res : result) {
|
||||
LOG.debug("Op Result {}", res);
|
||||
}
|
||||
}
|
||||
|
||||
Row row = null;
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult) && !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
row = ((SelectResult) result[0]).getRows().iterator().next();
|
||||
}
|
||||
|
||||
if( row != null ) {
|
||||
ret = row.getMapColumn("version_matrix");
|
||||
}
|
||||
|
||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
LOG.debug("getVersionMatrixFromNode {}", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
public void updateConfigVersionInNode(OvsdbClient ovsdbClient, long configVersionFromProfiles) {
|
||||
|
||||
try {
|
||||
//get original version_matrix map value
|
||||
Map<String, String> versionMatrix = getVersionMatrixFromNode(ovsdbClient);
|
||||
|
||||
//update our config version in version_matrix map
|
||||
versionMatrix.put(ConnectNodeInfo.CONFIG_VERSION_PROPERTY_NAME, Long.toString(configVersionFromProfiles));
|
||||
|
||||
//update the version_matrix column
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
com.vmware.ovsdb.protocol.operation.notation.Map<String, String> ovsdbVersionMatrix =
|
||||
com.vmware.ovsdb.protocol.operation.notation.Map.of(versionMatrix);
|
||||
updateColumns.put("version_matrix", ovsdbVersionMatrix);
|
||||
|
||||
Row row = new Row(updateColumns);
|
||||
operations.add(new Update(awlanNodeDbTable, row));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
for (OperationResult r : result) {
|
||||
LOG.debug("Op Result {}", r);
|
||||
}
|
||||
|
||||
LOG.debug("updateConfigVersionInNode {}", configVersionFromProfiles);
|
||||
|
||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ public class OvsdbClientWithMetrics implements OvsdbClient {
|
||||
this.delegate = delegate;
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
public OvsdbClient getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public CompletableFuture<String[]> listDatabases() throws OvsdbClientException {
|
||||
metrics.listDatabases.increment();
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.telecominfraproject.wlan.opensync.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.metrics.OvsdbClientWithMetrics;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
import com.vmware.ovsdb.service.impl.OvsdbClientImpl;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* Uses reflection to associate routingId with low-level netty channel.
|
||||
*
|
||||
* @author dtop
|
||||
*
|
||||
*/
|
||||
public class OvsdbClientUtil {
|
||||
|
||||
public static final AttributeKey<String> routingRecordIdAttrKey = AttributeKey.valueOf("routingRecordId");
|
||||
|
||||
|
||||
public static void setRoutingId(OvsdbClient ovsdbClient, long routingId) {
|
||||
Channel channel = getChannel(ovsdbClient);
|
||||
channel.attr(routingRecordIdAttrKey).set(Long.toString(routingId));
|
||||
}
|
||||
|
||||
public static Long getRoutingId(OvsdbClient ovsdbClient) {
|
||||
Channel channel = getChannel(ovsdbClient);
|
||||
String strVal = channel.attr(routingRecordIdAttrKey).get();
|
||||
return strVal==null?null:Long.parseLong(strVal);
|
||||
}
|
||||
|
||||
|
||||
private static Channel getChannel(OvsdbClient ovsdbClient) {
|
||||
if(ovsdbClient instanceof OvsdbClientWithMetrics) {
|
||||
//unwrap the object, if needed
|
||||
ovsdbClient = ((OvsdbClientWithMetrics) ovsdbClient).getDelegate();
|
||||
}
|
||||
|
||||
if(! (ovsdbClient instanceof OvsdbClientImpl)) {
|
||||
throw new RuntimeException("Do not know how to handle "+ ovsdbClient.getClass().getName()+" - expected OvsdbClientImpl");
|
||||
}
|
||||
|
||||
try {
|
||||
Field jsonRpcClientField = ovsdbClient.getClass().getDeclaredField("jsonRpcClient");
|
||||
jsonRpcClientField.setAccessible(true);
|
||||
Object jsonRpcClientObj = jsonRpcClientField.get(ovsdbClient);
|
||||
|
||||
Field transporterField = jsonRpcClientObj.getClass().getDeclaredField("transporter");
|
||||
transporterField.setAccessible(true);
|
||||
Object transporterObj = transporterField.get(jsonRpcClientObj);
|
||||
|
||||
Field channelField = transporterObj.getClass().getDeclaredField("val$channel");
|
||||
channelField.setAccessible(true);
|
||||
|
||||
Channel channel = (Channel) channelField.get(transporterObj);
|
||||
|
||||
return channel;
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException("Cannot get the channel for the ovsdbClient "+ ovsdbClient, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,6 +123,7 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
|
||||
Mockito.when(ovsdbSessionMapInterface.getSession("Test_Client_21P10C68818122")).thenReturn(ovsdbSession);
|
||||
|
||||
OpensyncAPConfig apConfig = Mockito.mock(OpensyncAPConfig.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
|
||||
Mockito.when(apConfig.getApProfile().getDetails()).thenReturn(Mockito.mock(ApNetworkConfiguration.class));
|
||||
|
||||
Mockito.when(opensyncExternalIntegrationInterface.getApConfig(Mockito.anyString())).thenReturn(apConfig);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.mockito.Mockito;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
@@ -86,10 +85,7 @@ public class OvsdbNodeTest {
|
||||
OvsdbRadiusProxyConfig ovsdbRadiusProxyConfig;
|
||||
@MockBean(answer = Answers.RETURNS_MOCKS)
|
||||
OvsdbGet ovsdbGet;
|
||||
|
||||
@Value("${tip.wlan.internalHostName:localhost}")
|
||||
private String internalHostName;
|
||||
|
||||
|
||||
MockitoSession mockito;
|
||||
|
||||
@Configuration
|
||||
@@ -126,7 +122,7 @@ public class OvsdbNodeTest {
|
||||
newMqttSettings.put("broker", ovsdbNode.mqttBrokerAddress);
|
||||
String mqttClientName = OvsdbToWlanCloudTypeMappingUtility.getAlteredClientCnIfRequired("AP-1", connectNodeInfo,
|
||||
false);
|
||||
newMqttSettings.put("topics", "/ap/opensync_mqtt_" + internalHostName + "/" + mqttClientName + "/opensync");
|
||||
newMqttSettings.put("topics", "/ap/" + mqttClientName + "/opensync");
|
||||
newMqttSettings.put("port", "" + ovsdbNode.mqttBrokerExternalPort);
|
||||
newMqttSettings.put("compress", "zlib");
|
||||
newMqttSettings.put("qos", "0");
|
||||
|
||||
Reference in New Issue
Block a user