Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/src/bootstrap/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class StatusTruncationConfig(EnumBackport):
RED_HAT = 'Red Hat'
SUSE = 'SUSE'
CENTOS = 'CentOS'
AZURE_LINUX = 'Microsoft Azure Linux'
AZURE_LINUX = ['Microsoft Azure Linux', 'Common Base Linux Mariner']

# Package Managers
APT = 'apt'
Expand Down
6 changes: 5 additions & 1 deletion src/core/src/bootstrap/EnvLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ def __init__(self, real_record_path=None, recorder_enabled=False, emulator_enabl
# Constant paths
self.etc_environment_file_path = "/etc/environment"

@staticmethod
def is_distro_azure_linux(distro_name):
return any(x in distro_name for x in Constants.AZURE_LINUX)

def get_package_manager(self):
""" Detects package manager type """
ret = None

if self.platform.linux_distribution()[0] == Constants.AZURE_LINUX:
if self.is_distro_azure_linux(str(self.platform.linux_distribution())):
code, out = self.run_command_output('which tdnf', False, False)
if code == 0:
ret = Constants.TDNF
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/package_managers/TdnfPackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ
# if an Auto Patching request comes in on a Azure Linux machine with Security and/or Critical classifications selected, we need to install all patches, since classifications aren't available in Azure Linux repository
installation_included_classifications = [] if execution_config.included_classifications_list is None else execution_config.included_classifications_list
if execution_config.health_store_id is not str() and execution_config.operation.lower() == Constants.INSTALLATION.lower() \
and Constants.AZURE_LINUX in str(env_layer.platform.linux_distribution()) \
and (env_layer.is_distro_azure_linux(str(env_layer.platform.linux_distribution()))) \
and 'Critical' in installation_included_classifications and 'Security' in installation_included_classifications:
self.composite_logger.log_debug("Updating classifications list to install all patches for the Auto Patching request since classification based patching is not available on Azure Linux machines")
execution_config.included_classifications_list = [Constants.PackageClassification.CRITICAL, Constants.PackageClassification.SECURITY, Constants.PackageClassification.OTHER]
Expand Down
10 changes: 7 additions & 3 deletions src/core/tests/Test_EnvLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ def mock_platform_system(self):
def mock_linux_distribution(self):
return ['test', 'test', 'test']

def mock_linux_distribution_to_return_azure_linux(self):
def mock_linux_distribution_to_return_azure_linux_3(self):
return ['Microsoft Azure Linux', '3.0', '']

def mock_linux_distribution_to_return_azure_linux_2(self):
return ['Common Base Linux Mariner', '2.0', '']

def mock_run_command_for_apt(self, cmd, no_output=False, chk_err=False):
if cmd.find("which apt-get") > -1:
return 0, ''
Expand Down Expand Up @@ -66,8 +69,9 @@ def test_get_package_manager(self):

test_input_output_table = [
[self.mock_run_command_for_apt, self.mock_linux_distribution, Constants.APT],
[self.mock_run_command_for_tdnf, self.mock_linux_distribution_to_return_azure_linux, Constants.TDNF],
[self.mock_run_command_for_yum, self.mock_linux_distribution_to_return_azure_linux, None], # check for Azure Linux machine which does not have tdnf
[self.mock_run_command_for_tdnf, self.mock_linux_distribution_to_return_azure_linux_3, Constants.TDNF],
[self.mock_run_command_for_yum, self.mock_linux_distribution_to_return_azure_linux_3, None], # check for Azure Linux machine which does not have tdnf
[self.mock_run_command_for_tdnf, self.mock_linux_distribution_to_return_azure_linux_2, Constants.TDNF],
[self.mock_run_command_for_yum, self.mock_linux_distribution, Constants.YUM],
[self.mock_run_command_for_zypper, self.mock_linux_distribution, Constants.ZYPPER],
]
Expand Down