From ff075f6ee795a590b244d70a90cc312ba1f2d83d Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Fri, 31 Aug 2018 06:25:51 -0400 Subject: 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 --- .../settings/phosphor-settings-defaults-native.bb | 18 ++++ .../phosphor-settings-defaults/defaults.yaml | 117 +++++++++++++++++++++ .../settings/phosphor-settings-manager.bb | 67 ++++++++++++ .../settings/phosphor-settings-manager.inc | 5 + .../phosphor-settings-manager/merge_settings.py | 58 ++++++++++ .../xyz.openbmc_project.Settings.service | 12 +++ .../phosphor-settings-read-settings-mrw-native.bb | 37 +++++++ .../mrw-override-settings.yaml | 3 + .../settings/phosphor-settings/merge_settings.py | 1 + 9 files changed, 318 insertions(+) create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.bb create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.inc create mode 100755 meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/merge_settings.py create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager/xyz.openbmc_project.Settings.service create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bb create mode 100644 meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml create mode 120000 meta-phosphor/recipes-phosphor/settings/phosphor-settings/merge_settings.py (limited to 'meta-phosphor/recipes-phosphor/settings') diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb new file mode 100644 index 000000000..37b8d4ef6 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults-native.bb @@ -0,0 +1,18 @@ +SUMMARY = "Default settings" +PR = "r1" + +inherit native +inherit obmc-phosphor-license +inherit phosphor-settings-manager + +SRC_URI += "file://defaults.yaml" + +PROVIDES += "virtual/phosphor-settings-defaults" + +S = "${WORKDIR}" + +do_install() { + DEST=${D}${settings_datadir} + install -d ${DEST} + install defaults.yaml ${DEST} +} diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml new file mode 100644 index 000000000..de00b8e68 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-defaults/defaults.yaml @@ -0,0 +1,117 @@ +/xyz/openbmc_project/control/minimum_ship_level_required: + - Interface: xyz.openbmc_project.Control.MinimumShipLevel + Properties: + MinimumShipLevelRequired: + Default: 'true' + +/xyz/openbmc_project/control/host0/auto_reboot: + - Interface: xyz.openbmc_project.Control.Boot.RebootPolicy + Properties: + AutoReboot: + Default: 'true' + +/xyz/openbmc_project/control/host0/boot: + - Interface: xyz.openbmc_project.Control.Boot.Source + Properties: + BootSource: + Default: Source::Sources::Default + - Interface: xyz.openbmc_project.Control.Boot.Mode + Properties: + BootMode: + Default: Mode::Modes::Regular + +/xyz/openbmc_project/control/host0/boot/one_time: + - Interface: xyz.openbmc_project.Control.Boot.Source + Properties: + BootSource: + Default: Source::Sources::Default + - Interface: xyz.openbmc_project.Control.Boot.Mode + Properties: + BootMode: + Default: Mode::Modes::Regular + - Interface: xyz.openbmc_project.Object.Enable + Properties: + Enabled: + Default: 'true' + +/xyz/openbmc_project/control/host0/power_cap: + - Interface: xyz.openbmc_project.Control.Power.Cap + Properties: + PowerCap: + Default: 0 + Validation: + Type: "range" + Validator: "0..1000" + Unit: "Watts" + PowerCapEnable: + Default: 'false' + +/xyz/openbmc_project/control/host0/power_restore_policy: + - Interface: xyz.openbmc_project.Control.Power.RestorePolicy + Properties: + PowerRestorePolicy: + Default: RestorePolicy::Policy::AlwaysOff + +/xyz/openbmc_project/time/owner: + - Interface: xyz.openbmc_project.Time.Owner + Properties: + TimeOwner: + Default: Owner::Owners::BMC + +/xyz/openbmc_project/time/sync_method: + - Interface: xyz.openbmc_project.Time.Synchronization + Properties: + TimeSyncMethod: + Default: Synchronization::Method::NTP + +/xyz/openbmc_project/network/host0/intf: + - Interface: xyz.openbmc_project.Network.MACAddress + Properties: + MACAddress: + Default: '"00:00:00:00:00:00"' + Validation: + Type: "regex" + Validator: '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$' + +#needs to implement address validation TODO openbmc/issues/2046 +/xyz/openbmc_project/network/host0/intf/addr: + - Interface: xyz.openbmc_project.Network.IP + Properties: + Address: + Default: '"0.0.0.0"' + PrefixLength: + Default: 0 + Validation: + Type: "range" + Validator: 0..128 + Unit: "bits" + Origin: + Default: IP::AddressOrigin::Static + Gateway: + Default: '"0.0.0.0"' + Type: + Default: IP::Protocol::IPv4 + +/xyz/openbmc_project/control/host0/restriction_mode: + - Interface: xyz.openbmc_project.Control.Security.RestrictionMode + Properties: + RestrictionMode: + Default: RestrictionMode::Modes::None + +/xyz/openbmc_project/control/host0/TPMEnable: + - Interface: xyz.openbmc_project.Control.TPM.Policy + Properties: + TPMEnable: + Default: 'false' + +/xyz/openbmc_project/control/power_supply_redundancy: + - Interface: xyz.openbmc_project.Control.PowerSupplyRedundancy + Properties: + PowerSupplyRedundancyEnabled: + Default: 'true' + +/xyz/openbmc_project/control/host0/turbo_allowed: + - Interface: xyz.openbmc_project.Control.Host.TurboAllowed + Properties: + TurboAllowed: + Default: 'true' diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.bb b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.bb new file mode 100644 index 000000000..a63a1f24a --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.bb @@ -0,0 +1,67 @@ +SUMMARY = "Phosphor Settings Manager" +DESCRIPTION = "Phosphor Settings Manager is an application that creates \ +d-bus objects to represent various user settings." +PR = "r1" + +inherit autotools +inherit obmc-phosphor-dbus-service +inherit pythonnative +inherit phosphor-settings-manager + +require phosphor-settings-manager.inc + +DBUS_SERVICE_${PN} = "xyz.openbmc_project.Settings.service" + +DEPENDS += "python-pyyaml-native" +DEPENDS += "python-mako-native" +DEPENDS += "autoconf-archive-native" +DEPENDS += "virtual/phosphor-settings-defaults" +DEPENDS += "${@df_enabled(d, 'obmc-mrw', 'phosphor-settings-read-settings-mrw-native')}" +DEPENDS += "sdbusplus sdbusplus-native" +DEPENDS += "phosphor-dbus-interfaces phosphor-dbus-interfaces-native" +DEPENDS += "phosphor-logging" +DEPENDS += "cereal" + +RDEPENDS_${PN} += "sdbusplus phosphor-dbus-interfaces" + +S = "${WORKDIR}/git" +SRC_URI += "file://merge_settings.py" + +EXTRA_OECONF = " \ + SETTINGS_YAML=${STAGING_DIR_NATIVE}${settings_datadir}/defaults.yaml \ + " + +# Collect files in SRC_URI that end in ".override.yml" and call a script that +# writes their contents over that of settings.yaml, which is then updated to +# the merged data values. +# This doesn't correctly handle globs in ".override.yml" entries in SRC_URI. +python do_merge_settings () { + import subprocess + + # TODO: Perform the merge in a temporary directory? + workdir = d.getVar('WORKDIR', True) + nativedir = d.getVar('STAGING_DIR_NATIVE', True) + settingsdir = d.getVar('settings_datadir', True) + settingsdir = settingsdir[1:] + settingsdir = os.path.join(nativedir, settingsdir) + cmd = [] + cmd.append(os.path.join(workdir, 'merge_settings.py')) + cmd.append(os.path.join(settingsdir, 'defaults.yaml')) + # Used for any settings from the MRW + use_mrw = df_enabled(d, 'obmc-mrw', 'true') + if (use_mrw == 'true'): + cmd.append(os.path.join(settingsdir, 'mrw-settings.override.yaml')) + + fetch = bb.fetch2.Fetch([], d) + override_urls = [url for url in fetch.urls if url.endswith('.override.yml')] + for url in override_urls: + bb.debug(2, 'Overriding with source: ' + url) + local_base = os.path.basename(fetch.localpath(url)) + filename = os.path.join(workdir, local_base) + cmd.append(filename) + + # Invoke the script and don't catch any resulting exception. + subprocess.check_call(cmd) +} +# python-pyyaml-native is installed by do_configure, so put this task after +addtask merge_settings after do_configure before do_compile diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.inc b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.inc new file mode 100644 index 000000000..b6c6b0b8a --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-manager.inc @@ -0,0 +1,5 @@ +HOMEPAGE = "http://github.com/openbmc/phosphor-settingsd" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc" +SRC_URI += "git://github.com/openbmc/phosphor-settingsd" +SRCREV = "58d2efeef84aa2812dfc249d7005c765c4b2091a" 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 [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} diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bb b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bb new file mode 100644 index 000000000..d5ec1bc53 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bb @@ -0,0 +1,37 @@ +# Generates MRW settings override yaml for phosphor-settings-manager +# The default YAML file, mrw-override-settings.yaml, is empty, therefore no +# settings will be overwritten. To override, modify mrw-override-settings.yaml. + +SUMMARY = "Generates MRW settings override YAML for phosphor-settings-manager." +PR = "r1" + +inherit native +inherit phosphor-settings-manager +inherit mrw-xml + +inherit obmc-phosphor-license + +DEPENDS += "mrw-native mrw-perl-tools-native" + +SRC_URI += "file://mrw-override-settings.yaml" + +S = "${WORKDIR}" + +MRW_EXPRESSION_VARS ?= "" + +do_install() { + DEST=${D}${config_datadir} + install -D mrw-override-settings.yaml ${DEST}/mrw-override-settings.yaml + + SETTINGS=${D}${settings_datadir} + install -d ${SETTINGS} + + # gen_settings.pl replaces any MRW variables with their value + ${bindir}/perl-native/perl \ + ${bindir}/gen_settings.pl \ + -i ${mrw_datadir}/${MRW_XML} \ + -s ${DEST}/mrw-override-settings.yaml \ + -o ${SETTINGS}/mrw-settings.override.yaml \ + ${MRW_EXPRESSION_VARS} \ + -f +} diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml new file mode 100644 index 000000000..c0fbedecc --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings-read-settings-mrw/mrw-override-settings.yaml @@ -0,0 +1,3 @@ +# Default MRW settings override definition YAML - empty. +# Any MRW variables, marked by MRW_, are replaced with their +# MRW value. diff --git a/meta-phosphor/recipes-phosphor/settings/phosphor-settings/merge_settings.py b/meta-phosphor/recipes-phosphor/settings/phosphor-settings/merge_settings.py new file mode 120000 index 000000000..f1395f001 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/settings/phosphor-settings/merge_settings.py @@ -0,0 +1 @@ +../phosphor-settings-manager/merge_settings.py \ No newline at end of file -- cgit v1.2.3