diff --git a/config/main.py b/config/main.py index 1b95c60b4a71..377a7adf322d 100755 --- a/config/main.py +++ b/config/main.py @@ -48,6 +48,16 @@ def log_error(msg): syslog.syslog(syslog.LOG_ERR, msg) syslog.closelog() +# +# Load asic_type for further use +# + +try: + version_info = sonic_device_util.get_sonic_version_info() + asic_type = version_info['asic_type'] +except KeyError, TypeError: + raise click.Abort() + # # Helper functions # @@ -314,6 +324,7 @@ def _abort_if_false(ctx, param, value): ctx.abort() def _stop_services(): + # on Mellanox platform pmon is stopped by syncd services_to_stop = [ 'swss', 'lldp', @@ -321,6 +332,8 @@ def _stop_services(): 'bgp', 'hostcfgd', ] + if asic_type == 'mellanox' and 'pmon' in services_to_stop: + services_to_stop.remove('pmon') for service in services_to_stop: try: @@ -358,6 +371,7 @@ def _reset_failed_services(): raise def _restart_services(): + # on Mellanox platform pmon is started by syncd services_to_restart = [ 'hostname-config', 'interfaces-config', @@ -369,6 +383,8 @@ def _restart_services(): 'lldp', 'hostcfgd', ] + if asic_type == 'mellanox' and 'pmon' in services_to_restart: + services_to_restart.remove('pmon') for service in services_to_restart: try: @@ -1350,8 +1366,7 @@ def asymmetric(ctx, interface_name, status): def platform(): """Platform-related configuration tasks""" -version_info = sonic_device_util.get_sonic_version_info() -if (version_info and version_info.get('asic_type') == 'mellanox'): +if asic_type == 'mellanox': platform.add_command(mlnx.mlnx) #