mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-16 01:45:02 +00:00
TW-20 - Read AP config from KDC instance
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.whizcontrol</groupId>
|
||||
<artifactId>root-pom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>ai.connectus</groupId>
|
||||
<artifactId>opensync_ext_interface</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>opensync_ext_interface</name>
|
||||
<description>Interface that defines how opensync gateway gets the AP config</description>
|
||||
<dependencies>
|
||||
@@ -15,6 +19,19 @@
|
||||
<groupId>ai.connectus</groupId>
|
||||
<artifactId>opensync_protobuf</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.vmware.ovsdb</groupId>
|
||||
<artifactId>ovsdb-client</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,8 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.whizcontrol</groupId>
|
||||
<artifactId>root-pom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>ai.connectus</groupId>
|
||||
<artifactId>opensync_ext_static</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>opensync_ext_static</name>
|
||||
<description>Configuration interface that provides static config from the file</description>
|
||||
<dependencies>
|
||||
|
||||
@@ -2,9 +2,12 @@ package ai.connectus.opensync.external.integration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ai.connectus.opensync.external.integration.OpensyncExternalIntegrationInterface;
|
||||
@@ -13,6 +16,7 @@ import sts.PlumeStats.Report;
|
||||
import traffic.NetworkMetadata.FlowReport;
|
||||
import wc.stats.IpDnsTelemetry.WCStatsReport;
|
||||
|
||||
@Profile("opensync_static_config")
|
||||
@Component
|
||||
public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegrationInterface {
|
||||
|
||||
@@ -21,6 +25,11 @@ public class OpensyncExternalIntegrationSimple implements OpensyncExternalIntegr
|
||||
@Value("${connectus.ovsdb.configFileName:/Users/dtop/Documents/TIP_WLAN_repos/opensync_wifi_controller/opensync_ext_static/src/main/resources/config_2_ssids.json}")
|
||||
private String configFileName;
|
||||
|
||||
@PostConstruct
|
||||
private void postCreate(){
|
||||
LOG.info("Using Static integration");
|
||||
}
|
||||
|
||||
public void apConnected(String apId) {
|
||||
LOG.info("AP {} got connected to the gateway", apId);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
<artifactId>opensync_ext_static</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.connectus</groupId>
|
||||
<artifactId>opensync_ext_kdc</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.vmware.ovsdb</groupId>
|
||||
|
||||
@@ -71,6 +71,8 @@ public class OpensyncMqttClient implements ApplicationListener<ContextClosedEven
|
||||
while(keepReconnecting) {
|
||||
BlockingConnection connection = null;
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
|
||||
// Create a new MQTT connection to the broker.
|
||||
/*
|
||||
* Using SSL connections
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package ai.connectus.opensync.ovsdb;
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@@ -19,6 +16,8 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener;
|
||||
|
||||
import ai.connectus.opensync.external.integration.OpensyncExternalIntegrationInterface;
|
||||
import ai.connectus.opensync.external.integration.OvsdbSession;
|
||||
import ai.connectus.opensync.external.integration.OvsdbSessionMapInterface;
|
||||
import ai.connectus.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import ai.connectus.opensync.ovsdb.dao.OvsdbDao;
|
||||
import ai.connectus.opensync.ovsdb.dao.models.ConnectNodeInfo;
|
||||
@@ -50,7 +49,8 @@ public class ConnectusOvsdbClient {
|
||||
@Autowired
|
||||
private OpensyncExternalIntegrationInterface extIntegrationInterface;
|
||||
|
||||
private final ConcurrentHashMap<String, OvsdbClient> connectedClients = new ConcurrentHashMap<>();
|
||||
@Autowired
|
||||
private OvsdbSessionMapInterface ovsdbSessionMapInterface;
|
||||
|
||||
@PostConstruct
|
||||
private void postCreate() {
|
||||
@@ -70,17 +70,20 @@ public class ConnectusOvsdbClient {
|
||||
String clientCn = SslUtil.extractCN(subjectDn);
|
||||
LOG.info("ovsdbClient connecting from {} on port {} clientCn {}", remoteHost, localPort, clientCn);
|
||||
|
||||
ConnectNodeInfo connectNodeInfo = processConnectRequest(ovsdbClient, clientCn);
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
|
||||
//successfully connected - register it in our connectedClients table
|
||||
//In Plume's environment clientCn is not unique that's why we are augmenting it with the serialNumber and using it as a key (equivalent of KDC unique qrCode)
|
||||
String key = clientCn + "_" + connectNodeInfo.serialNumber;
|
||||
ConnectusOvsdbClient.this.connectedClients.put(key, ovsdbClient);
|
||||
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.newSession(key, ovsdbClient);
|
||||
extIntegrationInterface.apConnected(key);
|
||||
|
||||
//push configuration to AP
|
||||
connectNodeInfo = processConnectRequest(ovsdbClient, clientCn, connectNodeInfo);
|
||||
|
||||
LOG.info("ovsdbClient connected from {} on port {} key {} ", remoteHost, localPort, key);
|
||||
|
||||
LOG.info("ovsdbClient connectedClients = {}", ConnectusOvsdbClient.this.connectedClients.size());
|
||||
LOG.info("ovsdbClient connectedClients = {}", ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions());
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("ovsdbClient error", e);
|
||||
@@ -105,19 +108,17 @@ public class ConnectusOvsdbClient {
|
||||
//disconnected - deregister ovsdbClient from our connectedClients table
|
||||
//unfortunately we only know clientCn at this point, but in Plume's environment they are not unique
|
||||
//so we are doing a reverse lookup here, and then if we find the key we will remove the entry from the connectedClients.
|
||||
String key = ConnectusOvsdbClient.this.connectedClients.searchEntries(1,
|
||||
(Entry<String, OvsdbClient> t) -> { return t.getValue().equals(ovsdbClient) ? t.getKey() : null ;}
|
||||
);
|
||||
String key = ConnectusOvsdbClient.this.ovsdbSessionMapInterface.lookupClientId(ovsdbClient);
|
||||
|
||||
if(key!=null) {
|
||||
ConnectusOvsdbClient.this.connectedClients.remove(key);
|
||||
ConnectusOvsdbClient.this.ovsdbSessionMapInterface.removeSession(key);
|
||||
extIntegrationInterface.apDisconnected(key);
|
||||
}
|
||||
|
||||
ovsdbClient.shutdown();
|
||||
|
||||
LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} key {} ", remoteHost, localPort, clientCn, key);
|
||||
LOG.info("ovsdbClient connectedClients = {}", ConnectusOvsdbClient.this.connectedClients.size());
|
||||
LOG.info("ovsdbClient connectedClients = {}", ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,10 +127,9 @@ public class ConnectusOvsdbClient {
|
||||
LOG.debug("manager waiting for connection on port {}...", ovsdbListenPort);
|
||||
}
|
||||
|
||||
private ConnectNodeInfo processConnectRequest(OvsdbClient ovsdbClient, String clientCn) {
|
||||
private ConnectNodeInfo processConnectRequest(OvsdbClient ovsdbClient, String clientCn, ConnectNodeInfo connectNodeInfo) {
|
||||
|
||||
LOG.debug("Starting Client connect");
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
connectNodeInfo = ovsdbDao.updateConnectNodeInfoOnConnect(ovsdbClient, clientCn, connectNodeInfo);
|
||||
|
||||
String apId = clientCn + "_" + connectNodeInfo.serialNumber;
|
||||
@@ -158,7 +158,7 @@ public class ConnectusOvsdbClient {
|
||||
}
|
||||
|
||||
public Set<String> getConnectedClientIds(){
|
||||
return new HashSet<>(connectedClients.keySet());
|
||||
return ovsdbSessionMapInterface.getConnectedClientIds();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,12 +167,12 @@ public class ConnectusOvsdbClient {
|
||||
* @return updated value of the redirector
|
||||
*/
|
||||
public String changeRedirectorAddress(String apId, String newRedirectorAddress) {
|
||||
OvsdbClient ovsdbClient = connectedClients.get(apId);
|
||||
if(ovsdbClient == null) {
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||
if(ovsdbSession == null) {
|
||||
throw new IllegalStateException("AP with id " + apId + " is not connected") ;
|
||||
}
|
||||
|
||||
String ret = ovsdbDao.changeRedirectorAddress(ovsdbClient, apId, newRedirectorAddress);
|
||||
String ret = ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PROFILES=" -Dspring.profiles.include=mqtt_receiver,ovsdb_redirector,ovsdb_manager"
|
||||
PROFILES=" -Dspring.profiles.include=mqtt_receiver,ovsdb_redirector,ovsdb_manager,opensync_static_config"
|
||||
|
||||
SSL_PROPS=" "
|
||||
SSL_PROPS+=" -Dssl.props=file:///home/ec2-user/opensync/ssl.properties"
|
||||
@@ -29,6 +29,20 @@ LOGGING_PROPS=" -Dlogging.config=file:///home/ec2-user/opensync/logback.xml"
|
||||
RESTAPI_PROPS=" "
|
||||
RESTAPI_PROPS+=" -Dserver.port=443"
|
||||
|
||||
export ALL_PROPS="$PROFILES $SSL_PROPS $CLIENT_MQTT_SSL_PROPS $OVSDB_PROPS $MQTT_PROPS $LOGGING_PROPS $RESTAPI_PROPS"
|
||||
PROV_SERVER="provService2.zone1.art2wave.com"
|
||||
SMEC_SERVER="smecService2.zone1.art2wave.com"
|
||||
|
||||
KDC_PROPS=" "
|
||||
KDC_PROPS+=" -Dwhizcontrol.orderAndSubscriptionManagementServiceBaseUrl=https://${PROV_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentAndNetworkManagementServiceBaseUrl=https://${PROV_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentConfigurationManagerServiceBaseUrl=https://${PROV_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentRoutingServiceBaseUrl=https://${PROV_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentStatusAndAlarmCollectorServiceBaseUrl=https://${SMEC_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentMetricsCollectorServiceBaseUrl=https://${SMEC_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.equipmentEventCollectorServiceBaseUrl=https://${SMEC_SERVER}"
|
||||
KDC_PROPS+=" -Dwhizcontrol.realTimeDataAnalyticsServiceBaseUrl=https://${SMEC_SERVER}"
|
||||
|
||||
|
||||
export ALL_PROPS="$PROFILES $SSL_PROPS $CLIENT_MQTT_SSL_PROPS $OVSDB_PROPS $MQTT_PROPS $LOGGING_PROPS $RESTAPI_PROPS $KDC_PROPS"
|
||||
|
||||
sudo java $ALL_PROPS -jar opensync_experiment-0.0.1-SNAPSHOT.jar > stdout.out 2>&1 &
|
||||
|
||||
Reference in New Issue
Block a user