@@ -29,11 +29,8 @@ class AzL3TdnfPackageManager(TdnfPackageManager):
29
29
def __init__ (self , env_layer , execution_config , composite_logger , telemetry_writer , status_handler ):
30
30
super (AzL3TdnfPackageManager , self ).__init__ (env_layer , execution_config , composite_logger , telemetry_writer , status_handler )
31
31
32
- # Support to get updates and their dependencies
33
- self .tdnf_check = 'sudo tdnf -q list updates <SNAPSHOTTIME>'
34
-
35
32
# Install update
36
- self .install_security_updates_azgps_coordinated_cmd = 'sudo tdnf -y upgrade --skip-broken <SNAPSHOTTIME> '
33
+ self .install_security_updates_azgps_coordinated_cmd = 'sudo tdnf -y upgrade --skip-broken'
37
34
38
35
# Strict SDP specializations
39
36
self .TDNF_MINIMUM_VERSION_FOR_STRICT_SDP = "3.5.8-3.azl3" # minimum version of tdnf required to support Strict SDP in Azure Linux
@@ -51,14 +48,11 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ
51
48
execution_config .included_classifications_list = [Constants .PackageClassification .CRITICAL , Constants .PackageClassification .SECURITY , Constants .PackageClassification .OTHER ]
52
49
53
50
# region Strict SDP using SnapshotTime
54
- @staticmethod
55
- def __generate_command_with_snapshotposixtime_if_specified (command_template , snapshot_posix_time = str ()):
56
- # type: (str, str) -> str
57
- if snapshot_posix_time == str ():
58
- return command_template .replace ('<SNAPSHOTTIME>' , str ())
51
+ def _Base__add_additional_parameters_as_required_to_cmd (self , cmd ):
52
+ if self .max_patch_publish_date == str ():
53
+ return cmd
59
54
else :
60
- return command_template .replace ('<SNAPSHOTTIME>' , ('--snapshottime={0}' .format (str (snapshot_posix_time ))))
61
- # endregion
55
+ return cmd + ' --snapshottime={0}' .format (str (self .max_patch_publish_date ))
62
56
63
57
# region Get Available Updates
64
58
# region Classification-based (incl. All) update check
@@ -69,28 +63,15 @@ def get_all_updates(self, cached=False):
69
63
self .composite_logger .log_debug ("[AzL3TDNF] Get all updates : [Cached={0}][PackagesCount={1}]]" .format (str (cached ), len (self .all_updates_cached )))
70
64
return self .all_updates_cached , self .all_update_versions_cached # allows for high performance reuse in areas of the code explicitly aware of the cache
71
65
72
- out = self .invoke_package_manager (self .__generate_command_with_snapshotposixtime_if_specified (self .tdnf_check , self . max_patch_publish_date ))
66
+ out = self .invoke_package_manager (self ._Base__add_additional_parameters_as_required_to_cmd (self .tdnf_check ))
73
67
self .all_updates_cached , self .all_update_versions_cached = self .extract_packages_and_versions (out )
74
68
self .composite_logger .log_debug ("[AzL3TDNF] Get all updates : [Cached={0}][PackagesCount={1}]]" .format (str (False ), len (self .all_updates_cached )))
75
69
return self .all_updates_cached , self .all_update_versions_cached
76
70
77
- def get_security_updates (self ):
78
- """Get missing security updates. NOTE: Classification based categorization of patches is not available in Azure Linux as of now"""
79
- self .composite_logger .log_verbose ("[AzL3TDNF] Discovering all packages as 'security' packages, since TDNF does not support package classification..." )
80
- security_packages , security_package_versions = self .get_all_updates (cached = False )
81
- self .composite_logger .log_debug ("[AzL3TDNF] Discovered 'security' packages. [Count={0}]" .format (len (security_packages )))
82
- return security_packages , security_package_versions
83
-
84
- def get_other_updates (self ):
85
- """Get missing other updates."""
86
- self .composite_logger .log_verbose ("[AzL3TDNF] Discovering 'other' packages..." )
87
- return [], []
88
-
89
71
def set_max_patch_publish_date (self , max_patch_publish_date = str ()):
90
72
"""Set the max patch publish date in POSIX time for strict SDP"""
91
- self .composite_logger .log_debug ("[AzL3TDNF] Setting max patch publish date. [MaxPatchPublishDate={0}]" .format (str (max_patch_publish_date )))
92
73
self .max_patch_publish_date = str (self .env_layer .datetime .datetime_string_to_posix_time (max_patch_publish_date , '%Y%m%dT%H%M%SZ' )) if max_patch_publish_date != str () else max_patch_publish_date
93
- self .composite_logger .log_debug ("[AzL3TDNF] Set max patch publish date. [MaxPatchPublishDatePosixTime ={0}]" .format (str (self .max_patch_publish_date )))
74
+ self .composite_logger .log_debug ("[AzL3TDNF] Set max patch publish date in posix time for Strict SDP . [MaxPatchPublishDate ={0}][MaxPatchPublishDatePosixTime={1}] " .format (str ( max_patch_publish_date ), str (self .max_patch_publish_date )))
94
75
# endregion
95
76
96
77
# endregion
@@ -101,7 +82,7 @@ def install_updates_fail_safe(self, excluded_packages):
101
82
102
83
def install_security_updates_azgps_coordinated (self ):
103
84
"""Install security updates in Azure Linux following strict SDP"""
104
- command = self .__generate_command_with_snapshotposixtime_if_specified (self .install_security_updates_azgps_coordinated_cmd , self . max_patch_publish_date )
85
+ command = self ._Base__add_additional_parameters_as_required_to_cmd (self .install_security_updates_azgps_coordinated_cmd )
105
86
out , code = self .invoke_package_manager_advanced (command , raise_on_exception = False )
106
87
return code , out
107
88
0 commit comments