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