配置 UI 持久高速缓存

此功能可缩短 UI 服务启动时间,并为资源类型和资源属性实现持久高速缓存。

概述

更新 common ConfigMap

KubernetesOpenShift® Container Platform 环境中执行这些步骤。

  1. 确保您在 noi 项目中。
  2. 转到 工作量 > ConfigMaps > 常见
  3. 单击 YAML 选项卡。
  4. 添加以下参数以在 data 部分中高速缓存所需的资源属性:
    cache.inventory.resourceProperties: '[accessIpAddress,ifName,ifSpeed]'
  5. 添加以下参数以在 data 部分中高速缓存所需的资源类型:
    cache.inventory.rootResourcesToCache: '[lac,gtpPeerEntityName]'
  6. 保存更改并重新启动 UI 服务。
    注: 将对添加的所有资源类型及其直接子代进行高速缓存。 将高速缓存所添加的所有资源属性及其关联的资源类型。
  1. 确保您在 tncp 项目中。
  2. 转到 配置和存储 > 配置地图 > 常见
  3. 单击 Edit resource (“编辑资源”图标)图标。
  4. 添加以下参数以在 data 部分中高速缓存所需的资源属性:
    cache.inventory.resourceProperties: '[accessIpAddress,ifName,ifSpeed]'
  5. 添加以下参数以在 data 部分中高速缓存所需的资源类型:
    cache.inventory.rootResourcesToCache: '[lac,gtpPeerEntityName]'
  6. 单击 更新
  7. 重新启动 UI 服务。

可选: 使用 REST API 进行随需应变高速缓存

如果您不想重新启动更新 common 配置映射后所需的 UI 服务,请改为使用以下 REST API 命令。 针对添加的资源属性和类型的高速缓存将持久存在,但不会在 common 配置映射中更新这些添加项。
注: 建议更新 common 配置映射,而不是使用 REST API。
  1. 确保您在 noitncp 项目中。
  2. 转到 工作量 > 豆荚 > ui-0
  3. 单击 终端 选项卡。
  4. 单击 Exec into pod (Exec 到 pod 图标) 图标
  5. 运行以下命令:
    • 使用以下命令获取认证 Cookie:
      curl -k --cookie-jar cookies.txt "https://<ui-instance>:30021/core/login?username=<npiadmin>&password=<npiadmin>"
    • 使用以下命令装入要高速缓存的资源属性:
      curl --cookie cookies.txt -k "https://<ui-instance>:30021/service/cache/load?resourceProperties=ifOperStatus,ifAdminStatus"
      {"types":[],
                "props":["ifOperStatus","ifAdminStatus"],
                "msg":"Cache config rootResourcesToCache and resourceProperties updated. Updated config will pickup by next cache syncup.
                  If there are more ui instances, then apply the same to other instances to ensure all instances are in sync.
                  Recommendation - Update rootResourcesToCache and resourceProperties in  common config to avoid losing them on the ui service restart."}
    • 使用以下命令卸载或除去要高速缓存的资源属性:
      curl --cookie cookies.txt -k "https://<ui-instance>:30021/service/cache/unload?resourceProperties=ifOperStatus,ifAdminStatus"
      {"types":[],
                "props":["ifOperStatus","ifAdminStatus"],
                "msg":"Unloading just applicale for externally loaded types and properties via rest only. Updated config will pickup by next cache syncup.
                If there are more ui instances, then apply the same to other instances to ensure all instances are in sync.
                Recommendation - Update rootResourcesToCache and resourceProperties in  common config to avoid losing them on the ui service restart."}
    • 使用以下命令装入要高速缓存的资源类型:
      curl --cookie cookies.txt -k "https://<ui-instance>:30021/service/cache/load?rootResourcesToCache=lac,gtpPeerEntityName"
      {"types":["lac","gtpPeerEntityName"],
                "props":[],
                "msg":"Cache config rootResourcesToCache and resourceProperties updated. Updated config will pickup by next cache syncup.
                  If there are more ui instances, then apply the same to other instances to ensure all instances are in sync.
                  Recommendation - Update rootResourcesToCache and resourceProperties in  common config to avoid losing them on the ui service restart."}
    • 使用以下命令卸载或除去要高速缓存的资源类型:
      curl --cookie cookies.txt -k "https://<ui-instance>:30021/service/cache/unload?rootResourcesToCache=lac,gtpPeerEntityName"
      {"types":["lac"],
                "props":[],
                "msg":"Unloading just applicale for externally loaded types and properties via rest only. Updated config will pickup by next cache syncup.
                If there are more ui instances, then apply the same to other instances to ensure all instances are in sync.
                Recommendation - Update rootResourcesToCache and resourceProperties in  common config to avoid losing them on the ui service restart."}
    • 列出使用以下命令添加的所有资源类型和资源属性:
      curl --cookie cookies.txt -k "https://<ui-instance>:30021/service/cache/getConfig"
      {"syncupTime":"1714223818055",
                "status":"LOADED",
                "types":"channel,radioSlot,powerSupply,ResourcesGroup,ssid,interface,temperature,ap,opticalPort,fan,chassis,snmpAgent,cpu,pool,cfmTest,wirelessController,card,probe,device,memory",
                "properties":"displayName,npiParentEntityId,targetAddress,ifIndex,parent,namespace_name,typeTest,node_name,remoteContext,npiIfIdIn,outFlowEnabled,state,npiIfIdOut,tenant,phase,scope,ifDescr,apIpAddress,shortDisplayName,node_is_ready,nativeType,wlanAdminStatus,itnmEntityId,id,apLocation,wlanQos,inFlowEnabled,apAdminStatus,sourceAddress,loadBalancingAlgorithm,ifName,type,vendor,npiEntityId,cluster_id,parentId,vsIpAddress,index,isNetflow",
                "partialLoaded":"",
                "ondemandtypes":"",
                "ondemandproperties":"ifOperStatus,ifAdminStatus"
                }"
  6. 更新要从缓存中添加或删除的特定属性。 例如,如果重置标志设置为 false,则 enDevType, displayName, ifName 属性将从缓存中删除。 从加载的缓存配置中删除这些资源类型,但不删除资源,然后再次更新。 如果重置标志为 false,则会将 API 中的 load_types 列表添加到现有配置中,并使用这些资源更新缓存。
    curl --cookie cookies.txt -k "https://ui-instance:30021/service/cache/updateConfig?configName=LOADED_PROPERTIES&properties=enDevType&reset=true"

    以逗号分隔的列表形式更新多个属性。

    curl --cookie cookies.txt -k "https://ui-instance:30021/service/cache/updateConfig?configName=LOADED_PROPERTIES&properties=displayName,vendor&reset=true"
    {
      "properties": "displayName,npiParentEntityId,targetAddress,ifIndex,parent,namespace_name,typeTest,node_name,remoteContext,npiIfIdIn,outFlowEnabled,state,npiIfIdOut,tenant,phase,scope,ifDescr,apIpAddress,shortDisplayName,ifSpeed,queueId,node_is_ready,nativeType,wlanAdminStatus,itnmEntityId,id,apLocation,wlanQos,inFlowEnabled,apAdminStatus,sourceAddress,loadBalancingAlgorithm,ifName,type,vendor,start,npiEntityId,cluster_id,parentId,vsIpAddress,index,isNetflow"
    }
  7. 更新要从缓存中添加或删除的特定资源类型。 例如,如果重置标志设置为 false,设备、接口、DU 和 GNB 资源类型将从缓存中删除。 从加载的缓存配置中删除这些资源类型,但不删除资源,然后再次更新。 如果重置标志为 false,则会将 API 中的 load_properties 列表添加到现有配置中,并使用这些属性更新缓存。
    curl --cookie cookies.txt -k "https://ui-instance:30021/service/cache/updateConfig?configName=LOADED_TYPES&type=device&reset=true"
    {
      "types": "powerSupply,ResourcesGroup,interface,temperature,fan,chassis,snmpAgent,cpu,pool,cfmTest,card,probe,device,memory"
    }

    以逗号分隔的列表形式更新多个资源类型。

    curl --cookie cookies.txt -k "https://ui-instance:30021/service/cache/updateConfig?configName=LOADED_TYPES&type=device,interface,DU,GNB&reset=true"