mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 11:07:49 +00:00
OVSDB AP Configuration: Profiles, Legacy Config Support
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
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.models.LocationDetails;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
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.routing.models.EquipmentGatewayRecord;
|
||||
import com.telecominfraproject.wlan.routing.models.EquipmentRoutingRecord;
|
||||
|
||||
@@ -13,11 +28,80 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
|
||||
private Equipment customerEquipment;
|
||||
private Profile apProfile;
|
||||
private Profile ssidProfile;
|
||||
private List<Profile> ssidProfile;
|
||||
private Location equipmentLocation;
|
||||
private EquipmentRoutingRecord equipmentRouting;
|
||||
private EquipmentGatewayRecord equipmentGateway;
|
||||
|
||||
// Handle Legacy Config Support
|
||||
public void setRadioConfig(OpensyncAPRadioConfig radioConfig) {
|
||||
|
||||
if (customerEquipment == null) {
|
||||
customerEquipment = new Equipment();
|
||||
customerEquipment.setId(0);
|
||||
customerEquipment.setEquipmentType(EquipmentType.AP);
|
||||
customerEquipment.setDetails(ApElementConfiguration.createWithDefaults());
|
||||
ApElementConfiguration apConfig = (ApElementConfiguration) customerEquipment.getDetails();
|
||||
apConfig.getRadioMap().get(RadioType.is2dot4GHz).setChannelNumber(radioConfig.getRadioChannel24G());
|
||||
apConfig.getRadioMap().get(RadioType.is5GHzL).setChannelNumber(radioConfig.getRadioChannel5LG());
|
||||
apConfig.getRadioMap().get(RadioType.is5GHzU).setChannelNumber(radioConfig.getRadioChannel5HG());
|
||||
customerEquipment.setDetails(apConfig);
|
||||
}
|
||||
|
||||
if (equipmentLocation == null) {
|
||||
equipmentLocation = new Location();
|
||||
equipmentLocation.setId(1);
|
||||
equipmentLocation.setDetails(LocationDetails.createWithDefaults());
|
||||
((LocationDetails) equipmentLocation.getDetails())
|
||||
.setCountryCode(CountryCode.getByName(radioConfig.getCountry().toLowerCase()));
|
||||
customerEquipment.setLocationId(equipmentLocation.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handle Legacy Config Support
|
||||
public void setSsidConfigs(List<OpensyncAPSsidConfig> ssidConfigs) {
|
||||
|
||||
if (apProfile == null) {
|
||||
apProfile = new Profile();
|
||||
apProfile.setName("GeneratedApProfile");
|
||||
apProfile.setId(2);
|
||||
apProfile.setDetails(ApNetworkConfiguration.createWithDefaults());
|
||||
}
|
||||
|
||||
long ssidProfileId = 3;
|
||||
for (OpensyncAPSsidConfig ssidConfig : ssidConfigs) {
|
||||
|
||||
Profile profile = new Profile();
|
||||
profile.setProfileType(ProfileType.ssid);
|
||||
profile.setName(ssidConfig.getSsid());
|
||||
SsidConfiguration cfg = SsidConfiguration.createWithDefaults();
|
||||
Set<RadioType> appliedRadios = new HashSet<RadioType>();
|
||||
appliedRadios.add(ssidConfig.getRadioType());
|
||||
cfg.setAppliedRadios(appliedRadios);
|
||||
cfg.setSsid(ssidConfig.getSsid());
|
||||
if (ssidConfig.getEncryption().equals("WPA-PSK") && ssidConfig.getMode().equals("1"))
|
||||
cfg.setSecureMode(SecureMode.wpaPSK);
|
||||
else
|
||||
cfg.setSecureMode(SecureMode.wpa2PSK);
|
||||
cfg.setBroadcastSsid(ssidConfig.isBroadcast() ? StateSetting.enabled : StateSetting.disabled);
|
||||
|
||||
profile.setDetails(cfg);
|
||||
profile.setId(ssidProfileId);
|
||||
if (this.ssidProfile == null)
|
||||
this.ssidProfile = new ArrayList<Profile>();
|
||||
this.ssidProfile.add(profile);
|
||||
apProfile.getChildProfileIds().add(ssidProfileId);
|
||||
ssidProfileId++;
|
||||
|
||||
}
|
||||
|
||||
if (customerEquipment != null) {
|
||||
customerEquipment.setProfileId(apProfile.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EquipmentGatewayRecord getEquipmentGateway() {
|
||||
return equipmentGateway;
|
||||
}
|
||||
@@ -50,11 +134,11 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
this.apProfile = apProfile;
|
||||
}
|
||||
|
||||
public Profile getSsidProfile() {
|
||||
public List<Profile> getSsidProfile() {
|
||||
return ssidProfile;
|
||||
}
|
||||
|
||||
public void setSsidProfile(Profile ssidProfile) {
|
||||
public void setSsidProfile(List<Profile> ssidProfile) {
|
||||
this.ssidProfile = ssidProfile;
|
||||
}
|
||||
|
||||
@@ -82,8 +166,13 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
ret.customerEquipment = customerEquipment.clone();
|
||||
if (equipmentLocation != null)
|
||||
ret.equipmentLocation = equipmentLocation.clone();
|
||||
if (ssidProfile != null)
|
||||
ret.ssidProfile = ssidProfile.clone();
|
||||
if (ssidProfile != null) {
|
||||
List<Profile> ssidList = new ArrayList<Profile>();
|
||||
for (Profile profile : ssidProfile) {
|
||||
ssidList.add(profile.clone());
|
||||
}
|
||||
ret.ssidProfile = ssidList;
|
||||
}
|
||||
if (apProfile != null)
|
||||
ret.apProfile = apProfile.clone();
|
||||
if (equipmentRouting != null)
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||
|
||||
public class OpensyncAPRadioConfig extends BaseJsonModel {
|
||||
|
||||
private static final long serialVersionUID = 5683558403622855381L;
|
||||
|
||||
private String country;
|
||||
private int radioChannel24G;
|
||||
private int radioChannel5LG;
|
||||
private int radioChannel5HG;
|
||||
|
||||
public int getRadioChannel24G() {
|
||||
return radioChannel24G;
|
||||
}
|
||||
|
||||
public void setRadioChannel24G(int radioChannel24G) {
|
||||
this.radioChannel24G = radioChannel24G;
|
||||
}
|
||||
|
||||
public int getRadioChannel5LG() {
|
||||
return radioChannel5LG;
|
||||
}
|
||||
|
||||
public void setRadioChannel5LG(int radioChannel5LG) {
|
||||
this.radioChannel5LG = radioChannel5LG;
|
||||
}
|
||||
|
||||
public int getRadioChannel5HG() {
|
||||
return radioChannel5HG;
|
||||
}
|
||||
|
||||
public void setRadioChannel5HG(int radioChannel5HG) {
|
||||
this.radioChannel5HG = radioChannel5HG;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpensyncAPRadioConfig clone() {
|
||||
return (OpensyncAPRadioConfig)super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||
|
||||
public class OpensyncAPSsidConfig extends BaseJsonModel {
|
||||
|
||||
private static final long serialVersionUID = -8540144450360788799L;
|
||||
|
||||
private RadioType radioType;
|
||||
private String ssid;
|
||||
private String encryption;
|
||||
private String key;
|
||||
private String mode;
|
||||
private boolean broadcast;
|
||||
|
||||
public RadioType getRadioType() {
|
||||
return radioType;
|
||||
}
|
||||
|
||||
public void setRadioType(RadioType radioType) {
|
||||
this.radioType = radioType;
|
||||
}
|
||||
|
||||
public String getSsid() {
|
||||
return ssid;
|
||||
}
|
||||
|
||||
public void setSsid(String ssid) {
|
||||
this.ssid = ssid;
|
||||
}
|
||||
|
||||
public String getEncryption() {
|
||||
return encryption;
|
||||
}
|
||||
|
||||
public void setEncryption(String encryption) {
|
||||
this.encryption = encryption;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public boolean isBroadcast() {
|
||||
return broadcast;
|
||||
}
|
||||
|
||||
public void setBroadcast(boolean broadcast) {
|
||||
this.broadcast = broadcast;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpensyncAPSsidConfig clone() {
|
||||
return (OpensyncAPSsidConfig)super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user