mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-10-31 18:47:57 +00:00
Wifi-1004: Provision gre_ifname, gre_local_inet_addr, gre_remote_inet_addr, gre_remote_mac_addr on AP
Wifi-999: JUnit updates opensync-gateway and opensync-ext-cloud Move the GreProfile attributes to the ApProfile.
This commit is contained in:
@@ -827,9 +827,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
|
||||
ret.setMetricsProfiles(
|
||||
profileContainer.getChildrenOfType(equipmentConfig.getProfileId(), ProfileType.metrics));
|
||||
|
||||
ret.setGreTunnelProfiles(
|
||||
profileContainer.getChildrenOfType(equipmentConfig.getProfileId(), ProfileType.gre_tunnel));
|
||||
|
||||
Set<Profile> radiusSet = new HashSet<>();
|
||||
Set<Long> captiveProfileIds = new HashSet<>();
|
||||
|
||||
@@ -35,7 +35,6 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
private List<Profile> ssidProfile;
|
||||
private List<Profile> metricsProfile;
|
||||
private List<Profile> radiusProfiles;
|
||||
private List<Profile> greTunnelProfiles;
|
||||
private Location equipmentLocation;
|
||||
private EquipmentRoutingRecord equipmentRouting;
|
||||
private EquipmentGatewayRecord equipmentGateway;
|
||||
@@ -237,12 +236,6 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
ret.radiusProfiles.add(radiusProfile);
|
||||
}
|
||||
}
|
||||
if (greTunnelProfiles != null) {
|
||||
ret.greTunnelProfiles = new ArrayList<>();
|
||||
for (Profile greTunnelProfile : this.greTunnelProfiles) {
|
||||
ret.greTunnelProfiles.add(greTunnelProfile);
|
||||
}
|
||||
}
|
||||
if (captiveProfiles != null) {
|
||||
ret.captiveProfiles = new ArrayList<>();
|
||||
for (Profile cpConfig : this.captiveProfiles) {
|
||||
@@ -267,16 +260,6 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
this.radiusProfiles = radiusProfiles;
|
||||
}
|
||||
|
||||
|
||||
public List<Profile> getGreTunnelProfiles() {
|
||||
return greTunnelProfiles;
|
||||
}
|
||||
|
||||
|
||||
public void setGreTunnelProfiles(List<Profile> greTunnelProfiles) {
|
||||
this.greTunnelProfiles = greTunnelProfiles;
|
||||
}
|
||||
|
||||
public List<Profile> getCaptiveProfiles() {
|
||||
return captiveProfiles;
|
||||
}
|
||||
@@ -304,7 +287,7 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(apProfile, blockedClients, bonjourGatewayProfiles, captiveProfiles, customerEquipment,
|
||||
equipmentGateway, equipmentLocation, equipmentRouting, greTunnelProfiles, hotspotConfig, metricsProfile,
|
||||
equipmentGateway, equipmentLocation, equipmentRouting, hotspotConfig, metricsProfile,
|
||||
radiusProfiles, rfProfile, ssidProfile);
|
||||
}
|
||||
|
||||
@@ -324,7 +307,6 @@ public class OpensyncAPConfig extends BaseJsonModel {
|
||||
&& Objects.equals(equipmentGateway, other.equipmentGateway)
|
||||
&& Objects.equals(equipmentLocation, other.equipmentLocation)
|
||||
&& Objects.equals(equipmentRouting, other.equipmentRouting)
|
||||
&& Objects.equals(greTunnelProfiles, other.greTunnelProfiles)
|
||||
&& Objects.equals(hotspotConfig, other.hotspotConfig)
|
||||
&& Objects.equals(metricsProfile, other.metricsProfile)
|
||||
&& Objects.equals(radiusProfiles, other.radiusProfiles) && Objects.equals(rfProfile, other.rfProfile)
|
||||
|
||||
@@ -66,7 +66,6 @@ import com.telecominfraproject.wlan.profile.bonjour.models.BonjourGatewayProfile
|
||||
import com.telecominfraproject.wlan.profile.bonjour.models.BonjourServiceSet;
|
||||
import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalAuthenticationType;
|
||||
import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.gre.tunnels.GreTunnelProfile;
|
||||
import com.telecominfraproject.wlan.profile.metrics.ChannelUtilizationSurveyType;
|
||||
import com.telecominfraproject.wlan.profile.metrics.ServiceMetricConfigParameters;
|
||||
import com.telecominfraproject.wlan.profile.metrics.ServiceMetricRadioConfigParameters;
|
||||
@@ -1704,7 +1703,7 @@ public class OvsdbDao {
|
||||
try {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
if (opensyncAPConfig == null || opensyncAPConfig.getGreTunnelProfiles() == null) {
|
||||
if (opensyncAPConfig == null || opensyncAPConfig.getApProfile() == null) {
|
||||
conditions.add(new Condition("if_type", Function.EQUALS, new Atom<>("gre")));
|
||||
operations.add(new Delete(wifiInetConfigDbTable, conditions));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
@@ -1717,18 +1716,16 @@ public class OvsdbDao {
|
||||
}
|
||||
} else {
|
||||
|
||||
Set<String> greSet = new HashSet<>();
|
||||
opensyncAPConfig.getGreTunnelProfiles().stream().forEach(p -> {
|
||||
GreTunnelProfile profileDetails = (GreTunnelProfile)p.getDetails();
|
||||
greSet.add(profileDetails.getGreTunnelName());
|
||||
});
|
||||
ApNetworkConfiguration profileDetails = (ApNetworkConfiguration) opensyncAPConfig.getApProfile()
|
||||
.getDetails();
|
||||
String greTunnelName = profileDetails.getGreTunnelName();
|
||||
|
||||
conditions.add(new Condition("if_type", Function.EQUALS, new Atom<>("gre")));
|
||||
operations.add(new Select(wifiInetConfigDbTable, conditions));
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
if (((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
LOG.debug("No Gre Tunnels present");
|
||||
return;
|
||||
@@ -1736,7 +1733,7 @@ public class OvsdbDao {
|
||||
operations.clear();
|
||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
||||
String ifName = row.getStringColumn("if_name");
|
||||
if (!greSet.contains(ifName)) {
|
||||
if (!greTunnelName.equals(ifName)) {
|
||||
List<Condition> deleteCondition = new ArrayList<>();
|
||||
deleteCondition.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName)));
|
||||
operations.add(new Delete(wifiInetConfigDbTable, deleteCondition));
|
||||
@@ -1747,14 +1744,14 @@ public class OvsdbDao {
|
||||
|
||||
ovsdbClient.transact(ovsdbName, operations);
|
||||
fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
for (OperationResult res : result) {
|
||||
LOG.debug("removeAllGreTunnels Op Result {}", res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||
LOG.error("Could not delete GreTunnel Configs", e);
|
||||
@@ -3258,28 +3255,25 @@ public class OvsdbDao {
|
||||
|
||||
public void configureGreTunnels(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
||||
|
||||
LOG.info("Configure Gre tunnels {}", opensyncApConfig.getGreTunnelProfiles());
|
||||
if (opensyncApConfig.getGreTunnelProfiles() != null) {
|
||||
for (Profile greTunnel : opensyncApConfig.getGreTunnelProfiles()) {
|
||||
configureGreTunnel(ovsdbClient, greTunnel);
|
||||
}
|
||||
LOG.info("Configure Gre tunnels {}", opensyncApConfig.getApProfile());
|
||||
if (opensyncApConfig.getApProfile() != null) {
|
||||
configureGreTunnel(ovsdbClient, opensyncApConfig.getApProfile());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void configureGreTunnel(OvsdbClient ovsdbClient, Profile greTunnelProfile) {
|
||||
private void configureGreTunnel(OvsdbClient ovsdbClient, Profile apNetworkConfiguration) {
|
||||
try {
|
||||
LOG.debug("Configure Gre Tunnel {}", greTunnelProfile);
|
||||
LOG.debug("Configure Gre Tunnel {}", apNetworkConfiguration);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> tableColumns = new HashMap<>();
|
||||
|
||||
GreTunnelProfile details = (GreTunnelProfile) greTunnelProfile.getDetails();
|
||||
ApNetworkConfiguration details = (ApNetworkConfiguration) apNetworkConfiguration.getDetails();
|
||||
tableColumns.put("gre_ifname", new Atom<>(details.getGreParentIfName()));
|
||||
tableColumns.put("gre_local_inet_addr", new Atom<>(details.getGreLocalInetAddr().getHostAddress()));
|
||||
tableColumns.put("gre_remote_inet_addr", new Atom<>(details.getGreRemoteInetAddr().getHostAddress()));
|
||||
if (details.getGreRemoteMacAddr() != null) {
|
||||
tableColumns.put("gre_remote_mac_addr",
|
||||
new Atom<>(details.getGreRemoteMacAddr().getAddressAsString()));
|
||||
tableColumns.put("gre_remote_mac_addr", new Atom<>(details.getGreRemoteMacAddr().getAddressAsString()));
|
||||
}
|
||||
tableColumns.put("if_name", new Atom<>(details.getGreTunnelName()));
|
||||
tableColumns.put("if_type", new Atom<>("gre"));
|
||||
@@ -3294,12 +3288,12 @@ public class OvsdbDao {
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
if (((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
LOG.debug("Adding new Gre Tunnel {}", greTunnelProfile);
|
||||
LOG.debug("Adding new Gre Tunnel {}", apNetworkConfiguration);
|
||||
|
||||
operations.clear();
|
||||
operations.add(new Insert(wifiInetConfigDbTable, new Row(tableColumns)));
|
||||
} else {
|
||||
LOG.debug("Updating Gre Tunnel {}", greTunnelProfile);
|
||||
LOG.debug("Updating Gre Tunnel {}", apNetworkConfiguration);
|
||||
operations.clear();
|
||||
operations.add(new Update(wifiInetConfigDbTable, conditions, new Row(tableColumns)));
|
||||
}
|
||||
@@ -3310,7 +3304,7 @@ public class OvsdbDao {
|
||||
LOG.debug("Configure Gre Tunnel Op Result {}", res);
|
||||
}
|
||||
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||
LOG.error("Couldn't configure Gre Tunnel {}", greTunnelProfile, e);
|
||||
LOG.error("Couldn't configure Gre Tunnel {}", apNetworkConfiguration, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import com.telecominfraproject.wlan.profile.gre.tunnels.GreTunnelProfile;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Atom;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
||||
@@ -130,23 +130,23 @@ public class OvsdbDaoTest {
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList()))
|
||||
.thenReturn(selectionFutureResult);
|
||||
Mockito.when(selectionFutureResult.get(30, TimeUnit.SECONDS)).thenReturn(operationResult);
|
||||
Profile greProfile = new Profile();
|
||||
greProfile.setCustomerId(2);
|
||||
greProfile.setId(1L);
|
||||
greProfile.setName("gre1");
|
||||
greProfile.setProfileType(ProfileType.gre_tunnel);
|
||||
GreTunnelProfile tunnelProfileDetails = GreTunnelProfile.createWithDefaults();
|
||||
Profile apProfile = new Profile();
|
||||
apProfile.setCustomerId(2);
|
||||
apProfile.setId(1L);
|
||||
apProfile.setName("ApProfile");
|
||||
apProfile.setProfileType(ProfileType.equipment_ap);
|
||||
ApNetworkConfiguration tunnelProfileDetails = ApNetworkConfiguration.createWithDefaults();
|
||||
|
||||
tunnelProfileDetails.setGreLocalInetAddr(InetAddress.getByName("10.0.10.10"));
|
||||
tunnelProfileDetails.setGreRemoteInetAddr(InetAddress.getByName("192.168.0.10"));
|
||||
tunnelProfileDetails.setGreTunnelName("gre1");
|
||||
tunnelProfileDetails.setGreParentIfName("wan");
|
||||
greProfile.setDetails(tunnelProfileDetails);
|
||||
List<Profile> greTunnelList = ImmutableList.of(greProfile);
|
||||
apProfile.setDetails(tunnelProfileDetails);
|
||||
OpensyncAPConfig apConfig = Mockito.mock(OpensyncAPConfig.class);
|
||||
Mockito.when(apConfig.getGreTunnelProfiles()).thenReturn(greTunnelList);
|
||||
Mockito.when(apConfig.getApProfile()).thenReturn(apProfile);
|
||||
ovsdbDao.removeAllGreTunnels(ovsdbClient, apConfig);
|
||||
|
||||
Mockito.verify(apConfig, Mockito.times(2)).getGreTunnelProfiles();
|
||||
Mockito.verify(apConfig, Mockito.times(2)).getApProfile();
|
||||
Mockito.verify(ovsdbClient, Mockito.times(1)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
|
||||
}
|
||||
@@ -173,27 +173,25 @@ public class OvsdbDaoTest {
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList()))
|
||||
.thenReturn(selectionFutureResult);
|
||||
Mockito.when(selectionFutureResult.get(30, TimeUnit.SECONDS)).thenReturn(operationResult);
|
||||
Profile greProfile = new Profile();
|
||||
greProfile.setCustomerId(2);
|
||||
greProfile.setId(1L);
|
||||
greProfile.setName("gre1");
|
||||
greProfile.setProfileType(ProfileType.gre_tunnel);
|
||||
GreTunnelProfile tunnelProfileDetails = GreTunnelProfile.createWithDefaults();
|
||||
Profile apProfile = new Profile();
|
||||
apProfile.setCustomerId(2);
|
||||
apProfile.setId(1L);
|
||||
apProfile.setName("ApProfile");
|
||||
apProfile.setProfileType(ProfileType.equipment_ap);
|
||||
ApNetworkConfiguration tunnelProfileDetails = ApNetworkConfiguration.createWithDefaults();
|
||||
|
||||
tunnelProfileDetails.setGreLocalInetAddr(InetAddress.getByName("10.0.10.10"));
|
||||
tunnelProfileDetails.setGreRemoteInetAddr(InetAddress.getByName("192.168.0.10"));
|
||||
tunnelProfileDetails.setGreTunnelName("gre1");
|
||||
tunnelProfileDetails.setGreParentIfName("wan");
|
||||
greProfile.setDetails(tunnelProfileDetails);
|
||||
Profile greProfile2 = greProfile.clone();
|
||||
greProfile2.setName("gre2");
|
||||
((GreTunnelProfile)greProfile2.getDetails()).setGreTunnelName("gre2");
|
||||
List<Profile> greTunnelList = ImmutableList.of(greProfile,greProfile2);
|
||||
apProfile.setDetails(tunnelProfileDetails);
|
||||
|
||||
OpensyncAPConfig apConfig = Mockito.mock(OpensyncAPConfig.class);
|
||||
Mockito.when(apConfig.getGreTunnelProfiles()).thenReturn(greTunnelList);
|
||||
Mockito.when(apConfig.getApProfile()).thenReturn(apProfile);
|
||||
ovsdbDao.configureGreTunnels(ovsdbClient, apConfig);
|
||||
// 2 calls to check existence, 2 calls to insert tunnel (1 each per Profile)
|
||||
Mockito.verify(ovsdbClient, Mockito.times(4)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.verify(apConfig, Mockito.times(3)).getGreTunnelProfiles();
|
||||
Mockito.verify(ovsdbClient, Mockito.times(2)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.verify(apConfig, Mockito.times(3)).getApProfile();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user