From 0206162c2d16ecb04f9bfe2790f58043620679f2 Mon Sep 17 00:00:00 2001 From: David Murphy < dmurphy@saltstack.com> Date: Mon, 5 Feb 2024 16:02:40 -0700 Subject: [PATCH] Moved get_machine_identifier temporiarly till sorted where it will be and what --- salt/utils/files.py | 14 ++++++++++++++ salt/utils/gitfs.py | 2 +- salt/utils/platform.py | 14 -------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/salt/utils/files.py b/salt/utils/files.py index e5494911c28..5f89e6aba98 100644 --- a/salt/utils/files.py +++ b/salt/utils/files.py @@ -904,3 +904,17 @@ def get_encoding(path): return "ASCII" raise CommandExecutionError("Could not detect file encoding") + + +## TBD DGM just parking here till final machine identifier work is done +def get_machine_identifier(): + """ + Provide the machine-identifier for machine/virtualization combination + """ + locations = ["/etc/machine-id", "/var/lib/dbus/machine-id"] + existing_locations = [loc for loc in locations if os.path.exists(loc)] + if not existing_locations: + return "" + else: + with fopen(existing_locations[0]) as machineid: + return machineid.read().strip() diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index 6d67f7c241d..ddc3e499782 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -250,7 +250,7 @@ class GitProvider: # DGM try getting machine_identifier # get machine_identifier - self.mach_id = salt.utils.platform.get_machine_identifier() + self.mach_id = salt.utils.files.get_machine_identifier() log.debug(f"machine_id for lock file, machine_id '{self.mach_id}'") self.global_saltenv = salt.utils.data.repack_dictlist( diff --git a/salt/utils/platform.py b/salt/utils/platform.py index b4f23034ba6..c6ca7fe8cae 100644 --- a/salt/utils/platform.py +++ b/salt/utils/platform.py @@ -12,7 +12,6 @@ import sys import distro from salt.utils.decorators import memoize as real_memoize -from salt.utils.files import fopen as _fopen def linux_distribution(full_distribution_name=True): @@ -240,16 +239,3 @@ def spawning_platform(): Salt, however, will force macOS to spawning by default on all python versions """ return multiprocessing.get_start_method(allow_none=False) == "spawn" - - -def get_machine_identifier(): - """ - Provide the machine-identifier for machine/virtualization combination - """ - locations = ["/etc/machine-id", "/var/lib/dbus/machine-id"] - existing_locations = [loc for loc in locations if os.path.exists(loc)] - if not existing_locations: - return "" - else: - with _fopen(existing_locations[0]) as machineid: - return machineid.read().strip()