From 59d9572d07b04cbadbe43ebe5616acf0465f0427 Mon Sep 17 00:00:00 2001 From: ibuler <ibuler@qq.com> Date: Wed, 22 Mar 2023 15:26:23 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20protocol=20?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/inventory.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index e3954c063..fb143cda5 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -99,7 +99,8 @@ class JMSInventory: if gateway: host.update(self.make_proxy_command(gateway)) - def asset_to_host(self, asset, account, automation, protocols, platform): + @staticmethod + def get_primary_protocol(protocols): primary_protocol = [p for p in protocols if p.primary] if len(primary_protocol) >= 1: primary = primary_protocol[0] @@ -114,6 +115,10 @@ class JMSInventory: else: protocol = 'null' port = 0 + return protocol, port + + def asset_to_host(self, asset, account, automation, protocols, platform): + protocol, port = self.get_primary_protocol(protocols) host = { 'name': '{}'.format(asset.name.replace(' ', '_')),