mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 02:57:49 +00:00
Removed static config file, using config from AllCloudInOneService, MQTT APClientMetrics
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.external.integration;
|
package com.telecominfraproject.wlan.opensync.external.integration;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@@ -20,22 +20,36 @@ import org.springframework.context.annotation.Profile;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
|
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
|
||||||
|
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
|
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
||||||
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||||
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||||
import com.telecominfraproject.wlan.customer.models.Customer;
|
import com.telecominfraproject.wlan.customer.models.Customer;
|
||||||
import com.telecominfraproject.wlan.customer.service.CustomerServiceInterface;
|
import com.telecominfraproject.wlan.customer.service.CustomerServiceInterface;
|
||||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.StateSetting;
|
||||||
|
import com.telecominfraproject.wlan.location.models.Location;
|
||||||
import com.telecominfraproject.wlan.location.service.LocationServiceInterface;
|
import com.telecominfraproject.wlan.location.service.LocationServiceInterface;
|
||||||
import com.telecominfraproject.wlan.opensync.experiment.OpenSyncConnectusController;
|
import com.telecominfraproject.wlan.opensync.experiment.OpenSyncConnectusController;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPInetState;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPInetState;
|
||||||
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPRadioConfig;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPRadioState;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPRadioState;
|
||||||
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPSsidConfig;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAWLANNode;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAWLANNode;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients;
|
||||||
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
|
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
|
||||||
|
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||||
|
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||||
|
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||||
|
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration.SecureMode;
|
||||||
import com.telecominfraproject.wlan.servicemetrics.models.ApClientMetrics;
|
import com.telecominfraproject.wlan.servicemetrics.models.ApClientMetrics;
|
||||||
import com.telecominfraproject.wlan.servicemetrics.models.ClientMetrics;
|
import com.telecominfraproject.wlan.servicemetrics.models.ClientMetrics;
|
||||||
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
|
import com.telecominfraproject.wlan.servicemetrics.models.SingleMetricRecord;
|
||||||
@@ -111,21 +125,40 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) {
|
public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) {
|
||||||
LOG.info("AP {} got connected to the gateway", apId);
|
LOG.info("AP {} got connected to the gateway", apId);
|
||||||
|
|
||||||
Customer customer = null; try { customer =
|
Customer customer = null;
|
||||||
customerServiceInterface.get(autoProvisionedCustomerId);
|
try {
|
||||||
LOG.debug("Got Customer {} for apId {}", customer.toPrettyString()); } catch
|
customer = customerServiceInterface.get(autoProvisionedCustomerId);
|
||||||
(Exception e) {
|
LOG.debug("Got Customer {} for apId {}", customer.toPrettyString(), apId);
|
||||||
LOG.error("Caught exception getting customer for Id {} for apId {}",
|
} catch (Exception e) {
|
||||||
autoProvisionedCustomerId, apId, e); }
|
LOG.error("Caught exception getting customer for Id {} for apId {}", autoProvisionedCustomerId, apId, e);
|
||||||
|
}
|
||||||
|
|
||||||
Equipment ce = null; try { ce = getCustomerEquipment(apId);
|
Equipment ce = null;
|
||||||
LOG.debug("Got Equipment {} for apId {}", ce.toPrettyString()); } catch
|
try {
|
||||||
(Exception e) {
|
ce = getCustomerEquipment(apId);
|
||||||
LOG.error("Caught exception getting equipment for Id {} for apId {}",
|
LOG.debug("Got Equipment {} for apId {}", ce.toPrettyString());
|
||||||
autoProvisionedEquipmentId, apId, e);
|
ce.setName(apId);
|
||||||
|
|
||||||
|
ce = equipmentServiceInterface.update(ce);
|
||||||
|
LOG.debug("Updated equipment {} for apId {}", ce.toPrettyString(), apId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Caught exception getting equipment for Id {} for apId {}", autoProvisionedEquipmentId, apId, e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Location> locationList = locationServiceInterface.getAllForCustomer(ce.getCustomerId());
|
||||||
|
for (Location location : locationList) {
|
||||||
|
LOG.debug("Location {} for Customer {}", location.toPrettyString(), ce.getCustomerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
PaginationResponse<com.telecominfraproject.wlan.profile.models.Profile> paginationResponse = profileServiceInterface
|
||||||
|
.getForCustomer(ce.getCustomerId(), new ArrayList<ColumnAndSort>(),
|
||||||
|
new PaginationContext<com.telecominfraproject.wlan.profile.models.Profile>(10));
|
||||||
|
|
||||||
|
for (com.telecominfraproject.wlan.profile.models.Profile profile : paginationResponse.getItems()) {
|
||||||
|
LOG.debug("Profile {} for Customer {}", profile.toPrettyString(), ce.getCustomerId());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||||
@@ -160,23 +193,123 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OpensyncAPConfig getApConfig(String apId) {
|
public OpensyncAPConfig getApConfig(String apId) {
|
||||||
|
LOG.info("Retrieving config for AP {} ", apId);
|
||||||
// TODO: connect to Cloud for config
|
|
||||||
// for now, take values for initial config from file
|
|
||||||
|
|
||||||
LOG.info("Retrieving config for AP {} from file {}", apId, configFileName);
|
|
||||||
OpensyncAPConfig ret = null;
|
OpensyncAPConfig ret = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ret = OpensyncAPConfig.fromFile(configFileName, OpensyncAPConfig.class);
|
|
||||||
} catch (IOException e) {
|
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||||
LOG.error("Cannot read config from {}", configFileName, e);
|
if (ovsdbSession == null) {
|
||||||
|
throw new IllegalStateException("AP is not connected " + apId);
|
||||||
|
}
|
||||||
|
long equipmentId = ovsdbSession.getEquipmentId();
|
||||||
|
Equipment resolvedEqCfg = equipmentServiceInterface.get(equipmentId);
|
||||||
|
|
||||||
|
if (resolvedEqCfg == null) {
|
||||||
|
throw new IllegalStateException("Cannot retrieve configuration for " + apId);
|
||||||
|
}
|
||||||
|
ret = new OpensyncAPConfig();
|
||||||
|
Location eqLocation = locationServiceInterface.get(resolvedEqCfg.getLocationId());
|
||||||
|
|
||||||
|
// extract country, radio channels from resolvedEqCfg
|
||||||
|
String country = "CA";
|
||||||
|
CountryCode countryCode = Location.getCountryCode(eqLocation);
|
||||||
|
if (countryCode != null && countryCode != CountryCode.UNSUPPORTED) {
|
||||||
|
country = countryCode.toString().toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
int radioChannel24G = 1;
|
||||||
|
int radioChannel5LG = 44;
|
||||||
|
int radioChannel5HG = 108;
|
||||||
|
|
||||||
|
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) resolvedEqCfg.getDetails();
|
||||||
|
|
||||||
|
Map<RadioType, ElementRadioConfiguration> erc = apElementConfiguration.getRadioMap();
|
||||||
|
if (erc != null) {
|
||||||
|
ElementRadioConfiguration erc24 = erc.get(RadioType.is2dot4GHz);
|
||||||
|
ElementRadioConfiguration erc5gl = erc.get(RadioType.is5GHzL);
|
||||||
|
ElementRadioConfiguration erc5gh = erc.get(RadioType.is5GHzU);
|
||||||
|
|
||||||
|
if (erc24 != null) {
|
||||||
|
radioChannel24G = erc24.getChannelNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (erc5gl != null) {
|
||||||
|
radioChannel5LG = erc5gl.getChannelNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (erc5gh != null) {
|
||||||
|
radioChannel5HG = erc5gh.getChannelNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpensyncAPRadioConfig radioConfig = new OpensyncAPRadioConfig();
|
||||||
|
radioConfig.setCountry(country);
|
||||||
|
radioConfig.setRadioChannel24G(radioChannel24G);
|
||||||
|
radioConfig.setRadioChannel5LG(radioChannel5LG);
|
||||||
|
radioConfig.setRadioChannel5HG(radioChannel5HG);
|
||||||
|
|
||||||
|
ret.setRadioConfig(radioConfig);
|
||||||
|
|
||||||
|
// extract ssid parameters from resolvedEqCfg
|
||||||
|
List<OpensyncAPSsidConfig> ssidConfigs = new ArrayList<>();
|
||||||
|
|
||||||
|
com.telecominfraproject.wlan.profile.models.Profile apProfile = profileServiceInterface
|
||||||
|
.get(resolvedEqCfg.getProfileId());
|
||||||
|
|
||||||
|
Set<Long> childProfileIds = apProfile.getChildProfileIds();
|
||||||
|
for (Long id : childProfileIds) {
|
||||||
|
com.telecominfraproject.wlan.profile.models.Profile profile = profileServiceInterface.get(id);
|
||||||
|
if (profile.getProfileType().equals(ProfileType.ssid)) {
|
||||||
|
SsidConfiguration ssidCfg = (SsidConfiguration) profile.getDetails();
|
||||||
|
|
||||||
|
for (RadioType radioType : ssidCfg.getAppliedRadios()) {
|
||||||
|
OpensyncAPSsidConfig osSsidCfg = new OpensyncAPSsidConfig();
|
||||||
|
|
||||||
|
osSsidCfg.setSsid(profile.getName());
|
||||||
|
osSsidCfg.setRadioType(radioType);
|
||||||
|
osSsidCfg.setBroadcast(ssidCfg.getBroadcastSsid() == StateSetting.enabled);
|
||||||
|
|
||||||
|
if (ssidCfg.getSecureMode() == SecureMode.wpa2OnlyPSK
|
||||||
|
|| ssidCfg.getSecureMode() == SecureMode.wpa2PSK) {
|
||||||
|
osSsidCfg.setEncryption("WPA-PSK");
|
||||||
|
osSsidCfg.setMode("2");
|
||||||
|
} else if (ssidCfg.getSecureMode() == SecureMode.wpaPSK) {
|
||||||
|
osSsidCfg.setEncryption("WPA-PSK");
|
||||||
|
osSsidCfg.setMode("1");
|
||||||
|
} else {
|
||||||
|
LOG.warn("Unsupported encryption mode {} - will use WPA-PSK instead",
|
||||||
|
ssidCfg.getSecureMode());
|
||||||
|
osSsidCfg.setEncryption("WPA-PSK");
|
||||||
|
osSsidCfg.setMode("2");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssidCfg.getKeyStr() == null) {
|
||||||
|
osSsidCfg.setKey("12345678");
|
||||||
|
} else {
|
||||||
|
osSsidCfg.setKey(ssidCfg.getKeyStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
ssidConfigs.add(osSsidCfg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.setSsidConfigs(ssidConfigs);
|
||||||
|
|
||||||
|
for (OpensyncAPSsidConfig osSsidCfg : ssidConfigs) {
|
||||||
|
LOG.debug("Mike OpensyncAPSsidConfig {}", osSsidCfg.toPrettyString());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Cannot read config for AP {}", apId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Config content : {}", ret);
|
LOG.debug("Config content : {}", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,8 +491,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
} else {
|
} else {
|
||||||
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0]));
|
apClientMetrics.setClientMetrics5g(clientMetrics.toArray(new ClientMetrics[0]));
|
||||||
}
|
}
|
||||||
|
LOG.debug("APClientMetrics Report {}", apClientMetrics.toPrettyString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processMqttMessage(String topic, FlowReport flowReport) {
|
public void processMqttMessage(String topic, FlowReport flowReport) {
|
||||||
|
|||||||
@@ -20,5 +20,5 @@
|
|||||||
<listAttribute key="org.eclipse.jdt.launching.MODULEPATH"/>
|
<listAttribute key="org.eclipse.jdt.launching.MODULEPATH"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="opensync-gateway-cloud-process"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="opensync-gateway-cloud-process"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--add-opens java.base/java.lang=ALL-UNNAMED -Dssl.props=file://${project_loc:opensync-gateway-cloud-process}/src/main/resources/app/certs/ssl.properties -Dtip.wlan.httpClientConfig=file://${project_loc:opensync-gateway-cloud-process}/src/main/resources/app/certs/httpClientConfig.json -Djavax.net.ssl.keyStore=${connectus_certs}/client_keystore.jks -Djavax.net.ssl.keyStorePassword=mypassword -Djavax.net.ssl.trustStore=${connectus_certs}/truststore.jks -Djavax.net.ssl.trustStorePassword=mypassword -Dconnectus.ovsdb.managerAddr=${local_server_address} -Dconnectus.ovsdb.listenPort=6640 -Dconnectus.ovsdb.redirector.listenPort=6643 -Dconnectus.ovsdb.timeoutSec=30 -Dconnectus.ovsdb.trustStore=${connectus_certs}/truststore.jks -Dconnectus.ovsdb.keyStore=${connectus_certs}/server.pkcs12 -Dconnectus.ovsdb.configFileName=${project_loc:opensync-ext-cloud}/src/main/resources/config_2_ssids.json -Dconnectus.mqttBroker.address=${local_server_address} -Dconnectus.mqttBroker.listenPort=1883 -Dtip.wlan.introspectTokenApi.host=localhost:9096 -Dtip.wlan.introspectTokenApi.clientToken=token_placeholder -Dtip.wlan.serviceUser=user -Dtip.wlan.servicePassword=password -Dspring.main.show-banner=false -Dserver.port=9096 -Dtip.wlan.secondaryPort=9097 -Dtip.wlan.csrf-enabled=false -Dspring.profiles.include=use_ssl,use_webtoken_auth,use_single_ds,RestTemplateConfiguration_X509_client_cert_auth,opensync_cloud_config,mqtt_receiver,ovsdb_redirector,ovsdb_manager"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--add-opens java.base/java.lang=ALL-UNNAMED -Dssl.props=file://${project_loc:opensync-gateway-cloud-process}/src/main/resources/app/certs/ssl.properties -Dtip.wlan.httpClientConfig=file://${project_loc:opensync-gateway-cloud-process}/src/main/resources/app/certs/httpClientConfig.json -Djavax.net.ssl.keyStore=${connectus_certs}/client_keystore.jks -Djavax.net.ssl.keyStorePassword=mypassword -Djavax.net.ssl.trustStore=${connectus_certs}/truststore.jks -Djavax.net.ssl.trustStorePassword=mypassword -Dconnectus.ovsdb.managerAddr=${local_server_address} -Dconnectus.ovsdb.listenPort=6640 -Dconnectus.ovsdb.redirector.listenPort=6643 -Dconnectus.ovsdb.timeoutSec=30 -Dconnectus.ovsdb.trustStore=${connectus_certs}/truststore.jks -Dconnectus.ovsdb.keyStore=${connectus_certs}/server.pkcs12 -Dconnectus.mqttBroker.address=${local_server_address} -Dconnectus.mqttBroker.listenPort=1883 -Dtip.wlan.introspectTokenApi.host=localhost:9096 -Dtip.wlan.introspectTokenApi.clientToken=token_placeholder -Dtip.wlan.serviceUser=user -Dtip.wlan.servicePassword=password -Dspring.main.show-banner=false -Dserver.port=9096 -Dtip.wlan.secondaryPort=9097 -Dtip.wlan.csrf-enabled=false -Dspring.profiles.include=use_ssl,use_webtoken_auth,use_single_ds,RestTemplateConfiguration_X509_client_cert_auth,opensync_cloud_config,mqtt_receiver,ovsdb_redirector,ovsdb_manager"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
Reference in New Issue
Block a user