diff --git a/setup.py b/setup.py index c954f03825..8cb4a7515f 100644 --- a/setup.py +++ b/setup.py @@ -216,6 +216,7 @@ 'toposort==1.6', 'www-authenticate==0.9.2', 'xmltodict==0.12.0', + 'lazy-object-proxy', ], setup_requires= [ 'pytest-runner', diff --git a/show/main.py b/show/main.py index 173c84bd7e..84f6cee981 100755 --- a/show/main.py +++ b/show/main.py @@ -5,6 +5,7 @@ import re import click +import lazy_object_proxy import utilities_common.cli as clicommon from sonic_py_common import multi_asic import utilities_common.multi_asic as multi_asic_util @@ -126,8 +127,8 @@ def run_command(command, display_cmd=False, return_cmd=False): if rc != 0: sys.exit(rc) -# Global class instance for SONiC interface name to alias conversion -iface_alias_converter = clicommon.InterfaceAliasConverter() +# Lazy global class instance for SONiC interface name to alias conversion +iface_alias_converter = lazy_object_proxy.Proxy(lambda: clicommon.InterfaceAliasConverter()) # # Display all storm-control data diff --git a/utilities_common/cli.py b/utilities_common/cli.py index c05069adcf..771bb9121e 100644 --- a/utilities_common/cli.py +++ b/utilities_common/cli.py @@ -7,6 +7,7 @@ import click import json +import lazy_object_proxy import netaddr from natsort import natsorted @@ -183,8 +184,8 @@ def alias_to_name(self, interface_alias): # interface_alias not in port_dict. Just return interface_alias return interface_alias if sub_intf_sep_idx == -1 else interface_alias + VLAN_SUB_INTERFACE_SEPARATOR + vlan_id -# Global class instance for SONiC interface name to alias conversion -iface_alias_converter = InterfaceAliasConverter() +# Lazy global class instance for SONiC interface name to alias conversion +iface_alias_converter = lazy_object_proxy.Proxy(lambda: InterfaceAliasConverter()) def get_interface_naming_mode(): mode = os.getenv('SONIC_CLI_IFACE_MODE')