sonic-buildimage/src/sonic-config-engine/sonic_platform.py
Joe LeVeque f49cac086f Remove extra trailing newlines at EOF (#804)
Files now end with a single newline
2017-07-12 20:54:37 -07:00

32 lines
902 B
Python

#!/usr/bin/env python
import os
DOCUMENTATION = '''
---
module: sonic_platform
version_added: "1.9"
short_description: Retrive platform related facts for a device.
description:
- Retrieve platform related facts from config files.
'''
def get_machine_info():
if not os.path.isfile('/host/machine.conf'):
return None
machine_vars = {}
with open('/host/machine.conf') as machine_file:
for line in machine_file:
tokens = line.split('=')
if len(tokens) < 2:
continue
machine_vars[tokens[0]] = tokens[1].strip()
return machine_vars
def get_platform_info(machine_info):
if machine_info != None:
if machine_info.has_key('onie_platform'):
return machine_info['onie_platform']
elif machine_info.has_key('aboot_platform'):
return machine_info['aboot_platform']
return None