diff --git a/dbm-ui/backend/db_services/mysql/dataclass.py b/dbm-ui/backend/db_services/mysql/dataclass.py index 1b3a368048..25cd40727e 100644 --- a/dbm-ui/backend/db_services/mysql/dataclass.py +++ b/dbm-ui/backend/db_services/mysql/dataclass.py @@ -8,9 +8,11 @@ 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. """ +import re from dataclasses import asdict, dataclass from typing import Dict, List +from backend.constants import IP_PORT_RE_PATTERN from backend.db_meta.enums.cluster_type import ClusterType @@ -44,4 +46,10 @@ def export_filter_conditions(self): if isinstance(filter_conditions["cluster_type"], list): filter_conditions["cluster_type__in"] = filter_conditions.pop("cluster_type") + # 如果是实例过滤. TODO: 临时给插件支持,后续统一替换成filter_clusters接口 + if re.compile(IP_PORT_RE_PATTERN).match(filter_conditions["immute_domain"]): + ip, port = filter_conditions.pop("immute_domain").split(":") + filter_conditions["storageinstance__machine__ip"] = ip + filter_conditions["storageinstance__port"] = port + return filter_conditions