From 22d70eb416db627a5b824aba11888cb8ca26f0b5 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 1 Apr 2024 15:07:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=8E=E4=B8=BA=E4=BA=A4=E6=8D=A2?= =?UTF-8?q?=E6=9C=BA=E6=89=A7=E8=A1=8C=E5=BF=AB=E6=8D=B7=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/inventory.py | 4 ++++ apps/ops/const.py | 1 + apps/ops/models/job.py | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index 44dab9435..cddea41fb 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -115,6 +115,10 @@ class JMSInventory: else: host.update(self.make_account_ansible_vars(account)) + if platform.name == 'Huawei': + host['ansible_connection'] = 'network_cli' + host['ansible_network_os'] = 'asa' + if gateway: ansible_connection = host.get('ansible_connection', 'ssh') if ansible_connection in ('local', 'winrm', 'rdp'): diff --git a/apps/ops/const.py b/apps/ops/const.py index 578697c48..61f0b5e32 100644 --- a/apps/ops/const.py +++ b/apps/ops/const.py @@ -54,6 +54,7 @@ class JobModules(models.TextChoices): postgresql = 'postgresql', _('PostgreSQL') sqlserver = 'sqlserver', _('SQLServer') raw = 'raw', _('Raw') + huawei = 'huawei', _('HUAWEI') class AdHocModules(models.TextChoices): diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 7c6f9e9ab..723369e25 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -66,7 +66,7 @@ class JMSPermedInventory(JMSInventory): 'mysql': ['mysql'], 'postgresql': ['postgresql'], 'sqlserver': ['sqlserver'], - 'ssh': ['shell', 'python', 'win_shell', 'raw'], + 'ssh': ['shell', 'python', 'win_shell', 'raw', 'huawei'], 'winrm': ['win_shell', 'shell'], } @@ -301,6 +301,11 @@ class JobExecution(JMSOrgBaseModel): shell += " chdir={}".format(self.current_job.chdir) if self.current_job.module in ['python']: shell += " executable={}".format(self.current_job.module) + + if module == JobModules.huawei.value: + module = 'ce_command' + shell = "commands=\"{}\" ".format(self.current_job.args) + return module, shell def get_runner(self):