Merge "Add python shim for docker config scripts"

This commit is contained in:
Zuul 2018-11-16 00:10:06 +00:00 committed by Gerrit Code Review
commit a459c6e6c9
4 changed files with 58 additions and 4 deletions

View File

@ -83,6 +83,9 @@ outputs:
exit 0
fi
exit $rc
pyshim.sh:
mode: "0700"
content: { get_file: ../../docker_config_scripts/pyshim.sh }
volumes_base:
description: Base volume list

View File

@ -184,7 +184,10 @@ outputs:
USER: {get_param: CephClientUserName}
owner: nova:nova
perm: '0600'
docker_config_scripts: {get_attr: [NovaComputeCommon, docker_config_scripts]}
docker_config_scripts:
map_merge:
- {get_attr: [ContainersCommon, docker_config_scripts]}
- {get_attr: [NovaComputeCommon, docker_config_scripts]}
docker_config:
step_3:
nova_statedir_owner:
@ -195,7 +198,7 @@ outputs:
volumes:
- /var/lib/nova:/var/lib/nova:shared,z
- /var/lib/docker-config-scripts/:/docker-config-scripts/
command: "/docker-config-scripts/nova_statedir_ownership.py"
command: "/docker-config-scripts/pyshim.sh /docker-config-scripts/nova_statedir_ownership.py"
step_4:
nova_compute:
image: *nova_compute_image

View File

@ -101,7 +101,10 @@ outputs:
- path: /var/log/nova
owner: nova:nova
recurse: true
docker_config_scripts: {get_attr: [NovaComputeCommon, docker_config_scripts]}
docker_config_scripts:
map_merge:
- {get_attr: [ContainersCommon, docker_config_scripts]}
- {get_attr: [NovaComputeCommon, docker_config_scripts]}
docker_config:
step_3:
nova_statedir_owner:
@ -112,7 +115,7 @@ outputs:
volumes:
- /var/lib/nova:/var/lib/nova:shared,z
- /var/lib/docker-config-scripts/:/docker-config-scripts/
command: "/docker-config-scripts/nova_statedir_ownership.py"
command: "/docker-config-scripts/pyshim.sh /docker-config-scripts/nova_statedir_ownership.py"
step_5:
nova_compute:
image: *nova_ironic_image

View File

@ -0,0 +1,45 @@
#!/bin/bash
# Copyright 2018 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Usage: pyshim.sh <script and/or arguments>
#
# Unfortunately THT doesn't know which version of python might be in a
# container so we need this script to be able to try python3 or python2
# depending on availability. Since this is a temporary shim until we've
# fully cut over to python3, we check for the existance of python3 first
# before falling back to python2. This will help in the transition from
# python2 based containers to python3.
show_usage() {
echo "Usage: pyshim.sh <script and/or arguments>"
}
if [ $# -lt 1 ]
then
show_usage
exit 1
fi
set -x
if command -v python3 >/dev/null; then
python3 "$@"
elif command -v python2 >/dev/null; then
python2 "$@"
elif command -v python >/dev/null; then
python "$@"
else
echo "ERROR: python is not available!"
exit 1
fi