mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-11-04 04:27:59 +00:00 
			
		
		
		
	WIFI-909: Provision Hotspot20_Icon_Config in opensync database via opensync gateway, using new Hotspot/passpoint profiles
WIFI-910: Provision Hotspot20_OSU_Providers in opensync database via opensync gateway, using new Hotspot/passpoint profiles WIFI-947: Add opensync gateway support for CEGWNewChannelRequest to change back-up channel in Wifi_RRM_Config Updated with handling of new schema, support osu_nai2 (shared), and osu provider name. Remove path from OSU Icons. Add support for Wifi_RRM_Config new backup channels
This commit is contained in:
		@@ -14,10 +14,6 @@ import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.service.GatewayType;
 | 
			
		||||
import com.telecominfraproject.wlan.core.client.PingClient;
 | 
			
		||||
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
@@ -30,8 +26,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import com.telecominfraproject.wlan.core.client.PingClient;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.service.GatewayType;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.service.ServiceInstanceInformation;
 | 
			
		||||
import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
 | 
			
		||||
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBaseCommand;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWChangeRedirectorHost;
 | 
			
		||||
@@ -41,6 +41,7 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCod
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNotification;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareFlashRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRadioResetRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRebootRequest;
 | 
			
		||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRouteCheck;
 | 
			
		||||
@@ -201,6 +202,9 @@ public class OpensyncCloudGatewayController {
 | 
			
		||||
                        ret.add(sendClientBlocklistChangeNotification(session,
 | 
			
		||||
                                (CEGWClientBlocklistChangeNotification) command));
 | 
			
		||||
                        break;
 | 
			
		||||
                    case NewChannelRequest:
 | 
			
		||||
                        ret.add(sendNewChannelRequest(session, (CEGWNewChannelRequest) command));
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
 | 
			
		||||
                        ret.add(new EquipmentCommandResponse(
 | 
			
		||||
@@ -289,6 +293,10 @@ public class OpensyncCloudGatewayController {
 | 
			
		||||
        return sendMessage(session, command.getInventoryId(), command);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private EquipmentCommandResponse sendNewChannelRequest(OvsdbSession session, CEGWNewChannelRequest command) {
 | 
			
		||||
        return sendMessage(session, command.getInventoryId(), command);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Deliver a message in payload to the CE
 | 
			
		||||
     *
 | 
			
		||||
@@ -318,6 +326,12 @@ public class OpensyncCloudGatewayController {
 | 
			
		||||
            tipwlanOvsdbClient.startDebugEngine(inventoryId, gatewayHostname, gatewayPort);
 | 
			
		||||
        } else if (command instanceof CEGWStopDebugEngine) {
 | 
			
		||||
            tipwlanOvsdbClient.stopDebugEngine(inventoryId);
 | 
			
		||||
        } else if (command instanceof CEGWNewChannelRequest) {
 | 
			
		||||
            CEGWNewChannelRequest request = (CEGWNewChannelRequest) command;
 | 
			
		||||
            Map<RadioType, Integer> newBackupChannels = request.getNewBackupChannels();
 | 
			
		||||
            String resultDetails = tipwlanOvsdbClient.processNewChannelsRequest(inventoryId, newBackupChannels);
 | 
			
		||||
            response.setResultDetail(resultDetails);
 | 
			
		||||
 | 
			
		||||
        } else if (command instanceof CEGWFirmwareDownloadRequest) {
 | 
			
		||||
 | 
			
		||||
            CEGWFirmwareDownloadRequest dlRequest = (CEGWFirmwareDownloadRequest) command;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,11 @@
 | 
			
		||||
package com.telecominfraproject.wlan.opensync.external.integration;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
 | 
			
		||||
 | 
			
		||||
public interface OvsdbClientInterface {
 | 
			
		||||
 | 
			
		||||
@@ -30,4 +32,6 @@ public interface OvsdbClientInterface {
 | 
			
		||||
    
 | 
			
		||||
    String processFactoryResetRequest(String apId);
 | 
			
		||||
    
 | 
			
		||||
    String processNewChannelsRequest(String apId, Map<RadioType,Integer> channelMap);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import com.google.common.collect.ImmutableMap;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
 | 
			
		||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
 | 
			
		||||
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface;
 | 
			
		||||
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface.RowUpdateOperation;
 | 
			
		||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbClientInterface;
 | 
			
		||||
@@ -856,4 +857,20 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
 | 
			
		||||
        }
 | 
			
		||||
        return key;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public  String processNewChannelsRequest(String apId, Map<RadioType,Integer> channelMap) {
 | 
			
		||||
        LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId);
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
 | 
			
		||||
            OvsdbClient ovsdbClient = session.getOvsdbClient();
 | 
			
		||||
            ovsdbDao.processNewChannelsRequest(ovsdbClient,channelMap);
 | 
			
		||||
            LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest change backup channels for AP   {}", apId);
 | 
			
		||||
            return "Triggered a factory reset of AP  " + apId;
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            LOG.error("TipWlanOvsdbClient::processNewChannelsRequest failed to change backup channels for AP {}", apId, e);
 | 
			
		||||
            return " failed to change backup channels for AP " + apId;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3697,9 +3697,15 @@ public class OvsdbDao {
 | 
			
		||||
                        Hotspot20IdProviderProfile providerProfile = (Hotspot20IdProviderProfile) provider.getDetails();
 | 
			
		||||
                        Map<String, Value> rowColumns = new HashMap<>();
 | 
			
		||||
                        rowColumns.put("osu_nai", new Atom<>(providerProfile.getOsuNaiStandalone()));
 | 
			
		||||
                        // rowColumns.put("osu_nai2", new
 | 
			
		||||
                        // Atom<>(providerProfile.getOsuNaiShared()));
 | 
			
		||||
 | 
			
		||||
                        // TODO: temporary check schema until AP has delivered
 | 
			
		||||
                        // changes.
 | 
			
		||||
                        if (schema.getTables().get(hotspot20OsuProvidersDbTable).getColumns().containsKey("osu_nai2")) {
 | 
			
		||||
                            rowColumns.put("osu_nai2", new Atom<>(providerProfile.getOsuNaiShared()));
 | 
			
		||||
                        }
 | 
			
		||||
                        if (schema.getTables().get(hotspot20OsuProvidersDbTable).getColumns()
 | 
			
		||||
                                .containsKey("osu_provider_name")) {
 | 
			
		||||
                            rowColumns.put("osu_provider_name", new Atom<>(provider.getName()));
 | 
			
		||||
                        }
 | 
			
		||||
                        getOsuIconUuidsForOsuProvider(ovsdbClient, providerProfile, rowColumns);
 | 
			
		||||
                        getOsuProviderFriendlyNames(providerProfile, rowColumns);
 | 
			
		||||
                        getOsuProviderMethodList(providerProfile, rowColumns);
 | 
			
		||||
@@ -3911,7 +3917,9 @@ public class OvsdbDao {
 | 
			
		||||
                            // "lang_code", "height", "img_type", "width" };
 | 
			
		||||
                            Map<String, Value> rowColumns = new HashMap<>();
 | 
			
		||||
                            rowColumns.put("name", new Atom<>(osuIcon.getIconName()));
 | 
			
		||||
                            if (schema.getTables().get(hotspot20IconConfigDbTable).getColumns().containsKey("path")) {
 | 
			
		||||
                                rowColumns.put("path", new Atom<>(osuIcon.getFilePath()));
 | 
			
		||||
                            }
 | 
			
		||||
                            rowColumns.put("url", new Atom<>(osuIcon.getImageUrl()));
 | 
			
		||||
                            rowColumns.put("lang_code", new Atom<>(osuIcon.getLanguageCode()));
 | 
			
		||||
                            rowColumns.put("height", new Atom<>(osuIcon.getIconHeight()));
 | 
			
		||||
@@ -4833,4 +4841,46 @@ public class OvsdbDao {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public void processNewChannelsRequest(OvsdbClient ovsdbClient, Map<RadioType, Integer> channelMap) {
 | 
			
		||||
 | 
			
		||||
        LOG.info("OvsdbDao::processNewChannelsRequest {}", channelMap);
 | 
			
		||||
        try {
 | 
			
		||||
            List<Operation> operations = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            channelMap.entrySet().stream().forEach(c -> {
 | 
			
		||||
                String freqBand = OvsdbToWlanCloudTypeMappingUtility.getOvsdbRadioFreqBandForRadioType(c.getKey());
 | 
			
		||||
                List<Condition> conditions = new ArrayList<>();
 | 
			
		||||
                conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
 | 
			
		||||
                Map<String, Value> updateColumns = new HashMap<>();
 | 
			
		||||
                updateColumns.put("backup_channel", new Atom<>(c.getValue()));
 | 
			
		||||
                Row row = new Row(updateColumns);
 | 
			
		||||
                operations.add(new Update(wifiRrmConfigDbTable, conditions, row));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
 | 
			
		||||
            OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
 | 
			
		||||
 | 
			
		||||
            if (LOG.isDebugEnabled()) {
 | 
			
		||||
                LOG.debug("processNewChannelsRequest::Update backup channel(s) for {}:", wifiRrmConfigDbTable);
 | 
			
		||||
 | 
			
		||||
                for (OperationResult res : result) {
 | 
			
		||||
                    LOG.debug("Op Result {}", res);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            LOG.info("Updated Wifi_RRM_Config");
 | 
			
		||||
 | 
			
		||||
        } catch (ExecutionException e) {
 | 
			
		||||
            LOG.error("Error in processNewChannelsRequest", e);
 | 
			
		||||
        } catch (OvsdbClientException | TimeoutException | InterruptedException e) {
 | 
			
		||||
            LOG.error("Error in processNewChannelsRequest", e);
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,10 +9,11 @@ import com.vmware.ovsdb.protocol.operation.notation.Uuid;
 | 
			
		||||
 | 
			
		||||
public class Hotspot20OsuProviders implements Cloneable {
 | 
			
		||||
 | 
			
		||||
    public static String[] ovsdbColumns = { "_version", "osu_nai", "osu_icons", "server_uri", "method_list", "_uuid",
 | 
			
		||||
            "osu_friendly_name", "service_description" };
 | 
			
		||||
    public static String[] ovsdbColumns = { "_version", "osu_nai", "osu_nai2", "osu_icons", "osu_provider_name",
 | 
			
		||||
            "server_uri", "method_list", "_uuid", "osu_friendly_name", "service_description" };
 | 
			
		||||
    public Uuid version;
 | 
			
		||||
    public Set<String> osuNai;
 | 
			
		||||
    public String osuNai;
 | 
			
		||||
    public String osuNai2;
 | 
			
		||||
    public Set<Uuid> osuIcons;
 | 
			
		||||
    public String serverUri;
 | 
			
		||||
    public Set<Integer> methodList;
 | 
			
		||||
@@ -26,7 +27,14 @@ public class Hotspot20OsuProviders implements Cloneable {
 | 
			
		||||
    public Hotspot20OsuProviders(Row row) {
 | 
			
		||||
        this.version = row.getUuidColumn("_version");
 | 
			
		||||
        this.uuid = row.getUuidColumn("_uuid");
 | 
			
		||||
        this.osuNai = row.getSetColumn("osu_nai");
 | 
			
		||||
        if ((row.getColumns().get("osu_nai") != null) && row.getColumns().get("osu_nai").getClass()
 | 
			
		||||
                .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
 | 
			
		||||
            this.osuNai = row.getStringColumn("osu_nai");
 | 
			
		||||
        }
 | 
			
		||||
        if ((row.getColumns().get("osu_nai2") != null) && row.getColumns().get("osu_nai2").getClass()
 | 
			
		||||
                .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
 | 
			
		||||
            this.osuNai2 = row.getStringColumn("osu_nai2");
 | 
			
		||||
        }
 | 
			
		||||
        this.osuIcons = row.getSetColumn("osu_icons");
 | 
			
		||||
        if ((row.getColumns().get("server_uri") != null) && row.getColumns().get("server_uri").getClass()
 | 
			
		||||
                .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
 | 
			
		||||
@@ -43,9 +51,6 @@ public class Hotspot20OsuProviders implements Cloneable {
 | 
			
		||||
        try {
 | 
			
		||||
            Hotspot20OsuProviders ret = (Hotspot20OsuProviders) super.clone();
 | 
			
		||||
 | 
			
		||||
            if (osuNai != null) {
 | 
			
		||||
                ret.osuNai = new HashSet<>(this.osuNai);
 | 
			
		||||
            }
 | 
			
		||||
            if (osuIcons != null) {
 | 
			
		||||
                ret.osuIcons = new HashSet<>(this.osuIcons);
 | 
			
		||||
            }
 | 
			
		||||
@@ -65,16 +70,9 @@ public class Hotspot20OsuProviders implements Cloneable {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Hotspot20OsuProviders [version=" + version + ", osuNai=" + osuNai + ", osuIcons=" + osuIcons
 | 
			
		||||
                + ", serverUri=" + serverUri + ", methodList=" + methodList + ", uuid=" + uuid + ", osuFriendlyName="
 | 
			
		||||
                + osuFriendlyName + ", serviceDescription=" + serviceDescription + "]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return Objects.hash(methodList, osuFriendlyName, osuIcons, osuNai, serverUri, serviceDescription, uuid,
 | 
			
		||||
        return Objects.hash(methodList, osuFriendlyName, osuIcons, osuNai, osuNai2, serverUri, serviceDescription, uuid,
 | 
			
		||||
                version);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -89,11 +87,17 @@ public class Hotspot20OsuProviders implements Cloneable {
 | 
			
		||||
        Hotspot20OsuProviders other = (Hotspot20OsuProviders) obj;
 | 
			
		||||
        return Objects.equals(methodList, other.methodList) && Objects.equals(osuFriendlyName, other.osuFriendlyName)
 | 
			
		||||
                && Objects.equals(osuIcons, other.osuIcons) && Objects.equals(osuNai, other.osuNai)
 | 
			
		||||
                && Objects.equals(serverUri, other.serverUri)
 | 
			
		||||
                && Objects.equals(osuNai2, other.osuNai2) && Objects.equals(serverUri, other.serverUri)
 | 
			
		||||
                && Objects.equals(serviceDescription, other.serviceDescription) && Objects.equals(uuid, other.uuid)
 | 
			
		||||
                && Objects.equals(version, other.version);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Hotspot20OsuProviders [version=" + version + ", osuNai=" + osuNai + ", osuNai2=" + osuNai2
 | 
			
		||||
                + ", osuIcons=" + osuIcons + ", serverUri=" + serverUri + ", methodList=" + methodList + ", uuid="
 | 
			
		||||
                + uuid + ", osuFriendlyName=" + osuFriendlyName + ", serviceDescription=" + serviceDescription + "]";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user