Return current environmental data in JSON

This commit is contained in:
Jeffrey Townsend
2016-07-14 17:38:43 +00:00
parent c575a267dc
commit 1d878e046d

View File

@@ -15,6 +15,7 @@ import os
import re
import yaml
import onl.YamlUtils
import subprocess
class OnlInfoObject(object):
DEFAULT_INDENT=" "
@@ -256,6 +257,11 @@ class OnlPlatformBase(object):
# is ma1 and lo
return 2
def environment(self):
yamlstr = subprocess.check_output(['/bin/onlpd', '-r', '-y'])
data = yaml.load(yamlstr);
return json.dumps(data, indent=4)
def __str__(self):
s = """Model: %s
Manufacturer: %s