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 --- .../ipmi/phosphor-ipmi-host/merge_yamls.py | 59 ++++++++++++++++++++++ .../phosphor-ipmi-host/phosphor-ipmi-host.service | 21 ++++++++ ...nbmc_project.Ipmi.Internal.SoftPowerOff.service | 14 +++++ 3 files changed, 94 insertions(+) create mode 100755 meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/merge_yamls.py create mode 100644 meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service create mode 100644 meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service (limited to 'meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host') diff --git a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/merge_yamls.py b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/merge_yamls.py new file mode 100755 index 000000000..5e6c4b5e6 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/merge_yamls.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +"""Copied from phosphor-settings-manager +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(0) + +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, default_flow_style=False) + print('Wrote merged target YAML file ' + target_filename) diff --git a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service new file mode 100644 index 000000000..3f10e11db --- /dev/null +++ b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service @@ -0,0 +1,21 @@ +[Unit] +Description=Phosphor Inband IPMI +# TODO openbmc/openbmc#2059 - The wants/after below should be based on providers +Wants=mapper-wait@-xyz-openbmc_project-control-host0-boot.service +After=mapper-wait@-xyz-openbmc_project-control-host0-boot.service +Wants=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service +After=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service +Wants=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service +After=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service +Wants=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service +After=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service +Wants=clear-once.service +After=clear-once.service + +[Service] +Restart=always +ExecStart=/usr/bin/env ipmid +SyslogIdentifier=ipmid + +[Install] +WantedBy={SYSTEMD_DEFAULT_TARGET} diff --git a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service new file mode 100644 index 000000000..600c86ac2 --- /dev/null +++ b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service @@ -0,0 +1,14 @@ +[Unit] +Description=Soft power off of the host +Wants=mapper-wait@-org-openbmc-HostIpmi-1.service +After=mapper-wait@-org-openbmc-HostIpmi-1.service +Wants=obmc-host-stopping@0.target +Before=obmc-host-stopping@0.target +Conflicts=obmc-host-start@0.target +ConditionPathExists=!/run/openbmc/host@0-request + +[Service] +Restart=no +ExecStart=/usr/bin/env phosphor-softpoweroff +SyslogIdentifier=phosphor-softpoweroff +Type=oneshot -- cgit v1.2.3