#!/bin/bash set -x centos_ver=$(rpm --eval %{centos_ver}) if [ "$centos_ver" == "7" ] ; then curl -o /etc/yum.repos.d/delorean.repo https://trunk.rdoproject.org/centos7/current/delorean.repo yum install -y python2-tripleo-repos ca-certificates tripleo-repos current-tripleo yum install -y python-crypto python2-novaclient python2-neutronclient python2-pyghmi os-net-config python2-os-client-config python2-openstackclient elif [ "$centos_ver" == "9" ] ; then curl -o /etc/yum.repos.d/delorean.repo https://trunk.rdoproject.org/centos${centos_ver}-master/current-tripleo/delorean.repo dnf install -y python3-tripleo-repos tripleo-repos current-tripleo dnf install -y openstack-network-scripts python3-cryptography python3-novaclient python3-pyghmi os-net-config python3-os-client-config python3-openstackclient else set +x $signal_command --data-binary '{"status": "FAILURE"}' echo "Unsupported CentOS version $centos_ver" exit 1 fi cat </usr/local/bin/openstackbmc $openstackbmc_script EOF chmod +x /usr/local/bin/openstackbmc # Configure clouds.yaml so we can authenticate to the host cloud mkdir -p ~/.config/openstack # Passing this as an argument is problematic because it has quotes inline that # cause syntax errors. Reading from a file should be easier. cat <<'EOF' >/tmp/bmc-cloud-data $cloud_data EOF python -c 'import json import sys import yaml with open("/tmp/bmc-cloud-data") as f: data=json.loads(f.read()) clouds={"clouds": {"host_cloud": data}} print(yaml.safe_dump(clouds, default_flow_style=False))' > ~/.config/openstack/clouds.yaml rm -f /tmp/bmc-cloud-data export OS_CLOUD=host_cloud # python script do query the cloud and write out the bmc services/configs $(command -v python3 || command -v python2) </dev/null then systemctl status openstack-bmc-* set +x $signal_command --data-binary '{"status": "FAILURE"}' echo "********** $unit failed to start **********" exit 1 fi set +x $signal_command --data-binary '{"status": "SUCCESS"}'