diff --git a/installer/scripts/omsadmin.sh b/installer/scripts/omsadmin.sh index bb7de3ad2..b42ed4f9a 100755 --- a/installer/scripts/omsadmin.sh +++ b/installer/scripts/omsadmin.sh @@ -53,11 +53,11 @@ AGENT_MAINTENANCE_MISSING_CONFIG_FILE=4 AGENT_MAINTENANCE_MISSING_CONFIG=5 AGENT_MAINTENANCE_ERROR_WRITING_TO_FILE=12 -# DSC MetaConfig generation script -if [ -x "$(command -v python2)" ]; then - METACONFIG_PY=/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py -elif [ -x "$(command -v python3)" ]; then +# DSC MetaConfig generation script. User python3 over python2 if both versions are installed +if [ -x "$(command -v python3)" ]; then METACONFIG_PY=/opt/microsoft/omsconfig/Scripts/python3/OMS_MetaConfigHelper.py +elif [ -x "$(command -v python2)" ]; then + METACONFIG_PY=/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py else # Failure to find python/the correct script path will only break onboarding (just one # of omsadmin's numerous functions); exit with failure in the onboard() function instead diff --git a/source/code/plugins/in_dsc_monitor.rb b/source/code/plugins/in_dsc_monitor.rb index 915bf6c4e..ce7299e79 100644 --- a/source/code/plugins/in_dsc_monitor.rb +++ b/source/code/plugins/in_dsc_monitor.rb @@ -57,11 +57,11 @@ def run_check_install def get_dsc_status begin - python = %x(which python2) + python = %x(which python3) if !python.empty? - dsc_status = %x(/opt/microsoft/omsconfig/Scripts/TestDscConfiguration.py) - else # assume python3, since /some/ python is an install prereq and we have a rescue below regardless dsc_status = %x(/opt/microsoft/omsconfig/Scripts/python3/TestDscConfiguration.py) + else # assume python2, since /some/ python is an install prereq and we have a rescue below regardless + dsc_status = %x(/opt/microsoft/omsconfig/Scripts/TestDscConfiguration.py) end rescue => error OMS::Log.error_once("Running TestDscConfiguration.py returned error : #{error}") diff --git a/test/code/plugins/in_dsc_monitor_plugintest.rb b/test/code/plugins/in_dsc_monitor_plugintest.rb index 11e5ff0d3..8352f8921 100644 --- a/test/code/plugins/in_dsc_monitor_plugintest.rb +++ b/test/code/plugins/in_dsc_monitor_plugintest.rb @@ -8,9 +8,9 @@ class DscMonitorTest < Test::Unit::TestCase TMP_DIR = File.dirname(__FILE__) + "/../tmp/test_dscmonitor" CHECK_IF_DPKG = "which dpkg > /dev/null 2>&1; echo $?" CHECK_DSC_INSTALL = "dpkg --list omsconfig > /dev/null 2>&1; echo $?" - CHECK_DSC_STATUS = "/opt/microsoft/omsconfig/Scripts/TestDscConfiguration.py" - CHECK_DSC_STATUS_PYTHON_3 = "/opt/microsoft/omsconfig/Scripts/python3/TestDscConfiguration.py" - CHECK_PYTHON = "which python2" + CHECK_DSC_STATUS = "/opt/microsoft/omsconfig/Scripts/python3/TestDscConfiguration.py" + CHECK_DSC_STATUS_PYTHON_2 = "/opt/microsoft/omsconfig/Scripts/TestDscConfiguration.py" + CHECK_PYTHON = "which python3" def setup Fluent::Test.setup @@ -64,8 +64,8 @@ def test_dsc_check_failure_message instance.should_receive(:`).with(CHECK_IF_DPKG).and_return(0) instance.should_receive(:`).with(CHECK_DSC_INSTALL).and_return(0) instance.should_receive(:`).with(CHECK_DSC_STATUS).and_return("Mock DSC config check") - instance.should_receive(:`).with(CHECK_DSC_STATUS_PYTHON_3).and_return("Mock DSC config check") - instance.should_receive(:`).with(CHECK_PYTHON).and_return("/usr/bin/python2") # as if python2 is installed + instance.should_receive(:`).with(CHECK_DSC_STATUS_PYTHON_2).and_return("Mock DSC config check") + instance.should_receive(:`).with(CHECK_PYTHON).and_return("/usr/bin/python3") # as if python3 is installed end d = create_driver @@ -91,8 +91,8 @@ def test_dsc_check_success_emits_no_messages instance.should_receive(:`).with(CHECK_IF_DPKG).and_return(0) instance.should_receive(:`).with(CHECK_DSC_INSTALL).and_return(0) instance.should_receive(:`).with(CHECK_DSC_STATUS).and_return(result) - instance.should_receive(:`).with(CHECK_DSC_STATUS_PYTHON_3).and_return(result) - instance.should_receive(:`).with(CHECK_PYTHON).and_return("/usr/bin/python2") # as if python2 is installed + instance.should_receive(:`).with(CHECK_DSC_STATUS_PYTHON_2).and_return(result) + instance.should_receive(:`).with(CHECK_PYTHON).and_return("") # as if python2 is installed end d = create_driver