Moved get_machine_identifier temporiarly till sorted where it will be and what

This commit is contained in:
David Murphy 2024-02-05 16:02:40 -07:00 committed by Daniel Wozniak
parent 563556eade
commit 0206162c2d
3 changed files with 15 additions and 15 deletions

View file

@ -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()

View file

@ -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(

View file

@ -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()