summaryrefslogtreecommitdiffstats
path: root/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2018-08-31 06:25:51 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-09-06 07:44:12 -0400
commitff075f6ee795a590b244d70a90cc312ba1f2d83d (patch)
treea617790bdbfdeef960665ba0242e1f0c93e5301a /meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager
parent3e4da38c127bb7e7641adc2fc41f4c33744cb918 (diff)
downloadtalos-openbmc-ff075f6ee795a590b244d70a90cc312ba1f2d83d.tar.gz
talos-openbmc-ff075f6ee795a590b244d70a90cc312ba1f2d83d.zip
meta-phosphor: Move layer content from common/
Adopt a more conventional directory hierarchy. meta-phosphor is still a _long_ way from suitable for hosting on yoctoproject.org but things like this don't help. (From meta-phosphor rev: 471cfcefa74b8c7ceb704cb670e6d915cf27c63b) Change-Id: I3f106b2f6cdc6cec734be28a6090800546f362eb Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager')
-rwxr-xr-xmeta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py58
-rw-r--r--meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/xyz.openbmc_project.Settings.service12
2 files changed, 70 insertions, 0 deletions
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py
new file mode 100755
index 000000000..01f5e3552
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+"""Loads a "target" YAML file and overwrites its values with values from
+"override" YAML files.
+
+Override files are processed in the order given.
+
+Usage:
+ merge_settings.py <target yaml> [override yamls]
+"""
+import sys
+import yaml
+import copy
+
+def dict_merge(target, source):
+ """Deep merge for dicts.
+
+ Works like dict.update() that recursively updates any dict values present in
+ both parameters.
+
+ Args:
+ target (dict): Values to be overwritten by corresponding values from
+ `source`.
+ source (dict): Overriding values. Not changed by call.
+
+ Returns:
+ `target` with values overwritten from those in `source` at any and all
+ levels of nested dicts.
+ """
+ if not isinstance(source, dict):
+ return source
+ for k, v in source.iteritems():
+ if k in target and isinstance(target[k], dict):
+ dict_merge(target[k], v)
+ else:
+ target[k] = copy.deepcopy(v)
+ return target
+
+if len(sys.argv) < 2:
+ sys.exit('Argument required: target yaml')
+
+if len(sys.argv) == 2:
+ # No overrides to handle
+ sys.exit()
+
+target_filename = sys.argv[1]
+with open(target_filename) as target_file:
+ data = yaml.safe_load(target_file)
+ print('Loaded target YAML file ' + target_filename)
+
+for override_filename in sys.argv[2:]:
+ with open(override_filename) as override_file:
+ override = yaml.safe_load(override_file)
+ dict_merge(data, override)
+ print('Merged override YAML file ' + override_filename)
+
+with open(target_filename, 'w') as target_file:
+ yaml.dump(data, target_file)
+ print('Wrote merged target YAML file ' + target_filename)
diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/xyz.openbmc_project.Settings.service b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/xyz.openbmc_project.Settings.service
new file mode 100644
index 000000000..50e21665c
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/xyz.openbmc_project.Settings.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Phosphor Settings Daemon
+
+[Service]
+ExecStart=/usr/bin/env phosphor-settings-manager
+SyslogIdentifier=phosphor-settings-manager
+Restart=always
+Type=dbus
+BusName={BUSNAME}
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}
OpenPOWER on IntegriCloud