From c981e9cd9ff13d9522a384831eafbd6e496f0890 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:05:42 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=B8=BB=E6=9C=BA=E5=90=8D=E5=8C=85?= =?UTF-8?q?=E5=90=AB/=20=E5=8F=AF=E4=BB=A5=E6=89=A7=E8=A1=8Cansible?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=20(#11772)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/utils.py | 2 +- apps/ops/ansible/inventory.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/accounts/utils.py b/apps/accounts/utils.py index fb3be63a7..ac896f8c0 100644 --- a/apps/accounts/utils.py +++ b/apps/accounts/utils.py @@ -16,7 +16,7 @@ class SecretGenerator: @staticmethod def generate_ssh_key(): - private_key, public_key = ssh_key_gen() + private_key, __ = ssh_key_gen() return private_key def generate_password(self): diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index 1c5fd17fc..1426ffc01 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -1,6 +1,7 @@ # ~*~ coding: utf-8 ~*~ import json import os +import re from collections import defaultdict from django.utils.translation import gettext as _ @@ -159,7 +160,7 @@ class JMSInventory: protocol = self.get_primary_protocol(ansible_config, protocols) tp, category = asset.type, asset.category - name = asset.name.replace(' ', '_').replace('[', '_').replace(']', '_') + name = re.sub(r'[ \[\]/]', '_', asset.name) secret_info = {k: v for k, v in asset.secret_info.items() if v} host = { 'name': name,