Add support for macOS High Sierra Base Images

This commit is contained in:
2Shirt 2021-03-17 01:23:12 -06:00
parent fa5eaf33f9
commit bc3f6946f7
2 changed files with 31 additions and 6 deletions

View file

@ -1290,7 +1290,10 @@ def ost_build_report(dev, dev_type):
# Description
report.append(dev.description)
if hasattr(dev, 'ram_total'):
report.append(f'{dev.ram_total} ({", ".join(dev.ram_dimms)})')
if len(dev.ram_dimms) == 1 and 'justTotalRAM' in dev.ram_dimms[0]:
report.append(f'{dev.ram_total} (Total - no DIMM info available)')
else:
report.append(f'{dev.ram_total} ({", ".join(dev.ram_dimms)})')
if hasattr(dev, 'serial') and dev.serial:
report.append(f'Serial Number: {dev.serial}')
report.append('')

View file

@ -2,6 +2,7 @@
# vim: sts=2 sw=2 ts=2
import logging
import os
import pathlib
import plistlib
import re
@ -151,11 +152,13 @@ class CpuRam(BaseObj):
def get_serial_number(self):
if PLATFORM == 'Darwin':
cmd = ['system_profiler', 'SPHardwareDataType']
proc = run_program(cmd, check=False)
match = MAC_SERIAL_REGEX.search(proc.stdout)
if match:
self.serial = match['serial'].strip()
cmd = (
'ioreg -c IOPlatformExpertDevice -d 2'
"| awk '/IOPlatformSerialNumber/ {print $3}'"
'| sed s/"//g'
)
proc = run_program(cmd, check=False, shell=True)
self.serial = proc.stdout.strip()
class Disk(BaseObj):
@ -815,6 +818,25 @@ def get_ram_list_linux():
def get_ram_list_macos():
"""Get RAM list under macOS."""
if os.path.exists('/usr/sbin/system_profiler'):
return get_ram_list_system_profiler()
# Failback option
return get_ram_list_sysctl()
def get_ram_list_sysctl():
"""Get RAM list using sysctl."""
cmd = ['sysctl', '-n', 'hw.memsize']
proc = run_program(cmd)
return [[
int(proc.stdout.strip()),
'justTotalRAM',
]]
def get_ram_list_system_profiler():
"""Get RAM list using system_profiler."""
dimm_list = []