diff --git a/config/main.py b/config/main.py index a2e0b37484..4076f55da2 100755 --- a/config/main.py +++ b/config/main.py @@ -46,6 +46,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 # @@ -287,13 +297,22 @@ def _abort_if_false(ctx, param, value): ctx.abort() def _stop_services(): - services_to_stop = [ - 'swss', - 'lldp', - 'pmon', - 'bgp', - 'hostcfgd', - ] + # on Mellanox platform pmon is stopped by syncd + if asic_type == 'mellanox': + services_to_stop = [ + 'swss', + 'lldp', + 'bgp', + 'hostcfgd', + ] + else: + services_to_stop = [ + 'swss', + 'lldp', + 'pmon', + 'bgp', + 'hostcfgd', + ] for service in services_to_stop: try: @@ -337,17 +356,30 @@ def _reset_failed_services(): raise def _restart_services(): - services_to_restart = [ - 'hostname-config', - 'interfaces-config', - 'ntp-config', - 'rsyslog-config', - 'swss', - 'bgp', - 'pmon', - 'lldp', - 'hostcfgd', - ] + # on Mellanox platform pmon is started by syncd + if asic_type == 'mellanox': + services_to_restart = [ + 'hostname-config', + 'interfaces-config', + 'ntp-config', + 'rsyslog-config', + 'swss', + 'bgp', + 'lldp', + 'hostcfgd', + ] + else: + services_to_restart = [ + 'hostname-config', + 'interfaces-config', + 'ntp-config', + 'rsyslog-config', + 'swss', + 'bgp', + 'pmon', + 'lldp', + 'hostcfgd', + ] for service in services_to_restart: try: @@ -1310,8 +1342,7 @@ def asymmetric(ctx, 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) #