diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java index e785701..9f0ad13 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java @@ -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 radiusSet = new HashSet<>(); Set captiveProfileIds = new HashSet<>(); diff --git a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPConfig.java b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPConfig.java index 295aac0..2186ba8 100644 --- a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPConfig.java +++ b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPConfig.java @@ -35,7 +35,6 @@ public class OpensyncAPConfig extends BaseJsonModel { private List ssidProfile; private List metricsProfile; private List radiusProfiles; - private List 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 getGreTunnelProfiles() { - return greTunnelProfiles; - } - - - public void setGreTunnelProfiles(List greTunnelProfiles) { - this.greTunnelProfiles = greTunnelProfiles; - } - public List 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) diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java index 8d10167..cdc1611 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java @@ -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 operations = new ArrayList<>(); List 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 fResult = ovsdbClient.transact(ovsdbName, operations); @@ -1717,18 +1716,16 @@ public class OvsdbDao { } } else { - Set 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 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 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 operations = new ArrayList<>(); Map 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 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); } diff --git a/opensync-gateway/src/test/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDaoTest.java b/opensync-gateway/src/test/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDaoTest.java index ba0ccb4..74255e0 100644 --- a/opensync-gateway/src/test/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDaoTest.java +++ b/opensync-gateway/src/test/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDaoTest.java @@ -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 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 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(); }