Add support for macOS High Sierra Base Images
This commit is contained in:
parent
fa5eaf33f9
commit
bc3f6946f7
2 changed files with 31 additions and 6 deletions
|
|
@ -1290,7 +1290,10 @@ def ost_build_report(dev, dev_type):
|
||||||
# Description
|
# Description
|
||||||
report.append(dev.description)
|
report.append(dev.description)
|
||||||
if hasattr(dev, 'ram_total'):
|
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:
|
if hasattr(dev, 'serial') and dev.serial:
|
||||||
report.append(f'Serial Number: {dev.serial}')
|
report.append(f'Serial Number: {dev.serial}')
|
||||||
report.append('')
|
report.append('')
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# vim: sts=2 sw=2 ts=2
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import plistlib
|
import plistlib
|
||||||
import re
|
import re
|
||||||
|
|
@ -151,11 +152,13 @@ class CpuRam(BaseObj):
|
||||||
|
|
||||||
def get_serial_number(self):
|
def get_serial_number(self):
|
||||||
if PLATFORM == 'Darwin':
|
if PLATFORM == 'Darwin':
|
||||||
cmd = ['system_profiler', 'SPHardwareDataType']
|
cmd = (
|
||||||
proc = run_program(cmd, check=False)
|
'ioreg -c IOPlatformExpertDevice -d 2'
|
||||||
match = MAC_SERIAL_REGEX.search(proc.stdout)
|
"| awk '/IOPlatformSerialNumber/ {print $3}'"
|
||||||
if match:
|
'| sed s/"//g'
|
||||||
self.serial = match['serial'].strip()
|
)
|
||||||
|
proc = run_program(cmd, check=False, shell=True)
|
||||||
|
self.serial = proc.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
class Disk(BaseObj):
|
class Disk(BaseObj):
|
||||||
|
|
@ -815,6 +818,25 @@ def get_ram_list_linux():
|
||||||
|
|
||||||
|
|
||||||
def get_ram_list_macos():
|
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."""
|
"""Get RAM list using system_profiler."""
|
||||||
dimm_list = []
|
dimm_list = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue