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
6 changes: 5 additions & 1 deletion src/core/src/bootstrap/ConfigurationFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from core.src.local_loggers.CompositeLogger import CompositeLogger

from core.src.package_managers.AptitudePackageManager import AptitudePackageManager
from core.src.package_managers.TdnfPackageManager import TdnfPackageManager
from core.src.package_managers.YumPackageManager import YumPackageManager
from core.src.package_managers.ZypperPackageManager import ZypperPackageManager

Expand Down Expand Up @@ -69,14 +70,17 @@ def __init__(self, log_file_path, real_record_path, recorder_enabled, emulator_e

self.configurations = {
'apt_prod_config': self.new_prod_configuration(Constants.APT, AptitudePackageManager),
'tdnf_prod_config': self.new_prod_configuration(Constants.TDNF, TdnfPackageManager),
'yum_prod_config': self.new_prod_configuration(Constants.YUM, YumPackageManager),
'zypper_prod_config': self.new_prod_configuration(Constants.ZYPPER, ZypperPackageManager),

'apt_dev_config': self.new_dev_configuration(Constants.APT, AptitudePackageManager),
'tdnf_dev_config': self.new_dev_configuration(Constants.TDNF, TdnfPackageManager),
'yum_dev_config': self.new_dev_configuration(Constants.YUM, YumPackageManager),
'zypper_dev_config': self.new_dev_configuration(Constants.ZYPPER, ZypperPackageManager),

'apt_test_config': self.new_test_configuration(Constants.APT, AptitudePackageManager),
'tdnf_test_config': self.new_test_configuration(Constants.TDNF, TdnfPackageManager),
'yum_test_config': self.new_test_configuration(Constants.YUM, YumPackageManager),
'zypper_test_config': self.new_test_configuration(Constants.ZYPPER, ZypperPackageManager)
}
Expand Down Expand Up @@ -112,7 +116,7 @@ def get_configuration(self, env, package_manager_name):
print ("Error: Environment configuration not supported - " + str(env))
return None

if str(package_manager_name) not in [Constants.APT, Constants.YUM, Constants.ZYPPER]:
if str(package_manager_name) not in [Constants.APT, Constants.TDNF, Constants.YUM, Constants.ZYPPER]:
print ("Error: Package manager configuration not supported - " + str(package_manager_name))
return None

Expand Down
4 changes: 3 additions & 1 deletion src/core/src/bootstrap/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ class StatusTruncationConfig(EnumBackport):
RED_HAT = 'Red Hat'
SUSE = 'SUSE'
CENTOS = 'CentOS'
AZURE_LINUX = 'Microsoft Azure Linux'

# Package Managers
APT = 'apt'
TDNF = 'tdnf'
YUM = 'yum'
ZYPPER = 'zypper'

Expand Down Expand Up @@ -350,7 +352,7 @@ class EnvLayer(EnumBackport):
PRIVILEGED_OP_REBOOT = PRIVILEGED_OP_MARKER + "Reboot_Exception"
PRIVILEGED_OP_EXIT = PRIVILEGED_OP_MARKER + "Exit_"

# Supported Package Architectures - if this is changed, review YumPackageManage
# Supported Package Architectures - if this is changed, review TdnfPackageManager and YumPackageManager
SUPPORTED_PACKAGE_ARCH = ['.x86_64', '.noarch', '.i686', '.aarch64']

# Package / Patch State Ordering Constants
Expand Down
37 changes: 22 additions & 15 deletions src/core/src/bootstrap/EnvLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EnvLayer(object):
def __init__(self, real_record_path=None, recorder_enabled=False, emulator_enabled=False):
# Recorder / emulator storage
self.__real_record_path = real_record_path
self.__real_record_pointer_path = real_record_path + ".pt"
self.__real_record_pointer_path = real_record_path + ".pt" if real_record_path is not None else None
self.__real_record_handle = None
self.__real_record_pointer = 0

Expand All @@ -55,7 +55,7 @@ def __init__(self, real_record_path=None, recorder_enabled=False, emulator_enabl
self.platform = self.Platform(recorder_enabled, emulator_enabled, self.__write_record, self.__read_record)
self.datetime = self.DateTime(recorder_enabled, emulator_enabled, self.__write_record, self.__read_record)
self.file_system = self.FileSystem(recorder_enabled, emulator_enabled, self.__write_record, self.__read_record,
emulator_root_path=os.path.dirname(self.__real_record_path))
emulator_root_path=os.path.dirname(self.__real_record_path) if self.__real_record_path is not None else self.__real_record_path)

# Constant paths
self.etc_environment_file_path = "/etc/environment"
Expand All @@ -64,20 +64,27 @@ def get_package_manager(self):
""" Detects package manager type """
ret = None

# choose default - almost surely one will match.
for b in ('apt-get', 'yum', 'zypper'):
code, out = self.run_command_output('which ' + b, False, False)
if self.platform.linux_distribution()[0] == Constants.AZURE_LINUX:
code, out = self.run_command_output('which tdnf', False, False)
if code == 0:
ret = b
if ret == 'apt-get':
ret = Constants.APT
break
if ret == 'yum':
ret = Constants.YUM
break
if ret == 'zypper':
ret = Constants.ZYPPER
break
ret = Constants.TDNF
else:
print("Error: Expected package manager tdnf not found on this Azure Linux VM")
else:
# choose default - almost surely one will match.
for b in ('apt-get', 'yum', 'zypper'):
code, out = self.run_command_output('which ' + b, False, False)
if code == 0:
ret = b
if ret == 'apt-get':
ret = Constants.APT
break
if ret == 'yum':
ret = Constants.YUM
break
if ret == 'zypper':
ret = Constants.ZYPPER
break

if ret is None and platform.system() == 'Windows':
ret = Constants.APT
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/core_logic/PatchAssessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def start_assessment(self):
self.lifecycle_manager.lifecycle_status_check()
return True

self.composite_logger.log("\nStarting patch assessment... [MachineId: " + self.env_layer.platform.node() +"][ActivityId: " + self.execution_config.activity_id +"][StartTime: " + self.execution_config.start_time +"]")
self.composite_logger.log("\nStarting patch assessment... [MachineId: " + self.env_layer.platform.node() + "][ActivityId: " + self.execution_config.activity_id + "][StartTime: " + self.execution_config.start_time + "]")
self.write_assessment_state() # success / failure does not matter, only that an attempt started

self.stopwatch.start()
Expand Down
Loading