Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): 统一城市字段 #8805 #8806

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dbm-ui/backend/db_services/dbbase/resources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ def _list_clusters(
"cluster_type": Q(cluster_type__in=query_params.get("cluster_type", "").split(",")),
# 版本
"major_version": Q(major_version__in=query_params.get("major_version", "").split(",")),
# 地域
# 地域 TODO: 城市统一为city字段,后续删除region字段
"city": Q(region__in=query_params.get("city", "").split(",")),
"region": Q(region__in=query_params.get("region", "").split(",")),
# 集群id列表
"cluster_ids": Q(id__in=query_params.get("cluster_ids")),
Expand Down Expand Up @@ -581,6 +582,7 @@ def _to_cluster_representation(
"bk_cloud_name": bk_cloud_name,
"major_version": cluster.major_version,
"region": cluster.region,
"city": cluster.region,
"db_module_name": db_module_names_map.get(cluster.db_module_id, ""),
"db_module_id": cluster.db_module_id,
"creator": cluster.creator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ListResourceSLZ(serializers.Serializer):
creator = serializers.CharField(required=False)
major_version = serializers.CharField(required=False)
region = serializers.CharField(required=False)
city = serializers.CharField(required=False)
cluster_ids = serializers.ListField(child=serializers.IntegerField(), required=False, allow_empty=True)
exact_domain = serializers.CharField(help_text=_("精确域名查询"), required=False)
status = serializers.CharField(required=False, help_text=_("状态"))
Expand Down
6 changes: 4 additions & 2 deletions dbm-ui/backend/db_services/ipchooser/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def format_hosts(cls, hosts: typing.List[types.HostInfo], bk_biz_id: int = 0) ->
"bk_mem": host.get("bk_mem"),
"bk_disk": host.get("bk_disk"),
"bk_cpu": host.get("bk_cpu"),
"bk_idc_name": host.get("idc_city_name"),
"bk_idc_id": host.get("idc_city_id"),
"bk_idc_name": host.get("idc_name"),
"bk_idc_id": host.get("idc_id"),
"bk_idc_city_name": host.get("idc_city_name"),
"bk_idc_city_id": host.get("idc_city_id"),
"bk_cpu_architecture": host.get("bk_cpu_architecture"),
"bk_cpu_module": host.get("bk_cpu_module"),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from collections import defaultdict
from typing import Any, Callable, Dict, List

from django.db.models import F, Q, QuerySet, Value
Expand Down Expand Up @@ -117,7 +117,7 @@ def _to_cluster_representation(

def get_remote_infos(insts: List[StorageInstance]):
"""获取remote信息,并补充分片信息"""
remote_infos = {InstanceInnerRole.MASTER.value: [], InstanceInnerRole.SLAVE.value: []}
remote_infos = defaultdict(list)
for inst in insts:
try:
related = "as_ejector" if inst.instance_inner_role == InstanceInnerRole.MASTER else "as_receiver"
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/backend/ticket/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,20 @@ def _get_base_info(host):
{
**_get_base_info(host_infos[0]),
"bk_city_code": host_infos[0].get("bk_idc_id") or default_agent_city_id,
"bk_city_name": host_infos[0].get("bk_idc_name", ""),
"bk_city_name": host_infos[0].get("bk_idc_city_name", ""),
}
]
# 构造gm的部署信息
gm_host_infos = [
{
**_get_base_info(host_infos[0]),
"bk_city_code": host_infos[0].get("bk_idc_id") or default_gm_city_ids[0],
"bk_city_name": host_infos[0].get("bk_idc_name", ""),
"bk_city_name": host_infos[0].get("bk_idc_city_name", ""),
},
{
**_get_base_info(host_infos[1]),
"bk_city_code": host_infos[1].get("bk_idc_id") or default_gm_city_ids[1],
"bk_city_name": host_infos[1].get("bk_idc_name", ""),
"bk_city_name": host_infos[1].get("bk_idc_city_name", ""),
},
]

Expand Down
Loading