diff --git a/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py b/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py index 91b66f5791..cfb390312c 100644 --- a/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py +++ b/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py @@ -140,7 +140,7 @@ def save_password(self): for username in self.info["usernames"]: for password_info in self.info["password_infos"]: - result = MongoDBPassword().save_password_to_db( + result = MongoDBPassword().save_password_to_db2( instances=password_info["nodes"], username=username, password=password_info["password"][username], diff --git a/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py b/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py index d749fbf521..2cf84b6aa2 100644 --- a/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py +++ b/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py @@ -67,6 +67,25 @@ def save_password_to_db(self, instances: list, username: str, password: str, ope else: return "" + def save_password_to_db2(self, instances: list, username: str, password: str, operator: str) -> str: + """不使用密码规则把密码保存到db中""" + + result = DBPrivManagerApi.modify_password( + { + "instances": instances, + "username": username, + "component": self.component, + "password": self.base64_encode(password), + "operator": operator, + "security_rule_name": "", + }, + raw=True, + ) + if result["code"] != RequestResultCode.Success.value: + return result["message"] + else: + return "" + def delete_password_from_db(self, instances: list, usernames: list) -> str: """ 从db中删除密码