Skip to content

Commit

Permalink
feat(backend): redis-cluster 支持存储访问入口 TencentBlueKing#7712
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Nov 4, 2024
1 parent ec2c3e6 commit 98ab771
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions dbm-ui/backend/db_meta/api/cluster/nosqlcomm/detail_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.translation import gettext as _

from backend.db_meta.api.cluster.base.graph import Graphic, Group, LineLabel
from backend.db_meta.enums import ClusterEntryRole
from backend.db_meta.enums import ClusterEntryRole, InstanceInnerRole
from backend.db_meta.models import Cluster, StorageInstanceTuple

logger = logging.getLogger("root")
Expand Down Expand Up @@ -43,9 +43,9 @@ def scan_cluster(cluster: Cluster) -> Graphic:
proxy_instance_group = None
for proxy_instance in cluster.proxyinstance_set.all():
dummy_proxy_instance_node, proxy_instance_group = graph.add_node(proxy_instance, proxy_instance_group)
backend_instance = proxy_instance.storageinstance.first()
backend_instance_grp = graph.get_or_create_group(*Group.generate_group_info(backend_instance))
graph.add_line(source=proxy_instance_group, target=backend_instance_grp, label=LineLabel.Access)
master_backend_instance = proxy_instance.storageinstance.first()
master_backend_instance_grp = graph.get_or_create_group(*Group.generate_group_info(master_backend_instance))
graph.add_line(source=proxy_instance_group, target=master_backend_instance_grp, label=LineLabel.Access)

master_bind_entry_group = Group(node_id="master_bind_entry_group", group_name=_("访问入口(主)"))
for bind_entry in proxy_instance.bind_entry.filter(role=ClusterEntryRole.MASTER_ENTRY.value):
Expand All @@ -54,8 +54,14 @@ def scan_cluster(cluster: Cluster) -> Graphic:

# 存储层访问入口
nodes_bind_entry_group = Group(node_id="nodes_bind_entry_group", group_name=_("存储层访问入口"))
for bind_entry in backend_instance.bind_entry.filter(role=ClusterEntryRole.NODE_ENTRY.value):
for bind_entry in master_backend_instance.bind_entry.filter(role=ClusterEntryRole.NODE_ENTRY.value):
dummy_be_node, nodes_bind_entry_group = graph.add_node(bind_entry, to_group=nodes_bind_entry_group)
graph.add_line(source=nodes_bind_entry_group, target=backend_instance_grp, label=LineLabel.Bind)
graph.add_line(source=nodes_bind_entry_group, target=master_backend_instance_grp, label=LineLabel.Bind)

slave_instance = cluster.storageinstance_set.filter(instance_inner_role=InstanceInnerRole.SLAVE.value).first()
slave_instance_group = graph.get_or_create_group(*Group.generate_group_info(slave_instance))
for bind_entry in master_backend_instance.bind_entry.filter(role=ClusterEntryRole.NODE_ENTRY.value):
dummy_be_node, nodes_bind_entry_group = graph.add_node(bind_entry, to_group=nodes_bind_entry_group)
graph.add_line(source=proxy_instance_group, target=slave_instance_group, label=LineLabel.Bind)

return graph

0 comments on commit 98ab771

Please sign in to comment.