Merge "Drop deprecated releasing tooling"
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
#!/usr/bin/env python2.7
|
||||
#
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
#
|
||||
# (c) 2016, Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
|
||||
#
|
||||
|
||||
|
||||
"""Read/write ansible-role-requirements.yml content from the CLI."""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import yaml
|
||||
|
||||
|
||||
# To ensure that the dicts are always output in the same order
|
||||
# we setup a representation for dict objects and register it
|
||||
# with the yaml class.
|
||||
def represent_dict(self, data):
|
||||
def key_function(elem):
|
||||
key = elem[0]
|
||||
# Prioritizes certain keys when sorting.
|
||||
prio = {"model": 0, "pk": 1, "fields": 2}.get(key, 99)
|
||||
return (prio, key)
|
||||
items = data.items()
|
||||
items.sort(key=key_function)
|
||||
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
||||
|
||||
|
||||
yaml.add_representer(dict, represent_dict)
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the main application."""
|
||||
|
||||
# Setup argument parsing
|
||||
parser = argparse.ArgumentParser(
|
||||
description='ansible-role-requirements.yml CLI editor',
|
||||
epilog='Licensed "Apache 2.0"')
|
||||
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
'--file',
|
||||
help='<Required> ansible-role-requirements.yml file location',
|
||||
required=True
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-n',
|
||||
'--name',
|
||||
help='<Required> The name of the Ansible role to edit',
|
||||
required=True
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-v',
|
||||
'--version',
|
||||
help='<Required> The version to set for the Ansible role',
|
||||
required=True
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-s',
|
||||
'--src',
|
||||
help='<Optional> The source URL to set for the Ansible role',
|
||||
required=False
|
||||
)
|
||||
|
||||
# Parse arguments
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read the ansible-role-requirements.yml file into memory
|
||||
with open(args.file, "r") as role_req_file:
|
||||
reqs = yaml.safe_load(role_req_file)
|
||||
|
||||
# Loop through the list to find the applicable role
|
||||
for role_data in reqs:
|
||||
if role_data['name'] == args.name:
|
||||
# Change the specified role data
|
||||
role_data['version'] = args.version
|
||||
if args.src:
|
||||
role_data['src'] = args.src
|
||||
|
||||
# Write out the resulting file
|
||||
with open(args.file, "w") as role_req_file:
|
||||
try:
|
||||
yaml.dump(reqs, role_req_file, default_flow_style=False)
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -1,104 +0,0 @@
|
||||
#!/usr/bin/env python2.7
|
||||
#
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
#
|
||||
# (c) 2016, Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
|
||||
#
|
||||
|
||||
|
||||
"""Returns the versions of a list of pypi packages you specify."""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import xmlrpclib
|
||||
|
||||
PRE_RELEASE_RE = re.compile('a|b|rc')
|
||||
|
||||
|
||||
def get_package_version(pypiConn, pkg_name):
|
||||
"""Get the current package version from PyPI."""
|
||||
pkg_result = [v for v in pypiConn.package_releases(pkg_name, True)
|
||||
if not PRE_RELEASE_RE.search(v)]
|
||||
if pkg_result:
|
||||
pkg_version = pkg_result[0]
|
||||
else:
|
||||
pkg_version = 'Not available.'
|
||||
|
||||
return pkg_version
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the main application."""
|
||||
|
||||
# Setup argument parsing
|
||||
parser = argparse.ArgumentParser(
|
||||
description='PyPI Current Package Version Checker',
|
||||
epilog='Licensed "Apache 2.0"')
|
||||
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
'--format',
|
||||
choices=['requirements', 'bare'],
|
||||
default='requirements',
|
||||
help='<Optional> Output format',
|
||||
required=False
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-l',
|
||||
'--layout',
|
||||
choices=['vertical', 'horizontal'],
|
||||
default='vertical',
|
||||
help='<Optional> Output layout',
|
||||
required=False
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-p',
|
||||
'--packages',
|
||||
nargs='+',
|
||||
help='<Required> Space-delimited list of packages',
|
||||
required=True
|
||||
)
|
||||
|
||||
# Parse arguments
|
||||
args = parser.parse_args()
|
||||
|
||||
# Setup pypi object
|
||||
pypi = xmlrpclib.ServerProxy('https://pypi.org/project/pypi')
|
||||
|
||||
# Setup the newline if the results layout should be vertical
|
||||
# Also add a space delimiter appropriately
|
||||
if args.layout == 'vertical':
|
||||
delimiter = ''
|
||||
endline = '\n'
|
||||
else:
|
||||
delimiter = ' '
|
||||
endline = ''
|
||||
|
||||
# Print the results to stdout
|
||||
for pkg_name in args.packages:
|
||||
pkg_version = get_package_version(pypi, pkg_name)
|
||||
if args.format == 'requirements':
|
||||
print(pkg_name + '==' + pkg_version + delimiter, end=endline)
|
||||
else:
|
||||
print(pkg_version + delimiter, end=endline)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -1,141 +0,0 @@
|
||||
#!/usr/bin/env python2.7
|
||||
#
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
#
|
||||
# (c) 2016, Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
|
||||
#
|
||||
|
||||
|
||||
"""Read ansible-role-requirements.yml content from the CLI and output
|
||||
yaml content to stdout to be used when submitting release requests."""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
from cStringIO import StringIO
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import yaml
|
||||
|
||||
|
||||
# To ensure that the dicts are always output in the same order
|
||||
# we setup a representation for dict objects and register it
|
||||
# with the yaml class.
|
||||
def represent_dict(self, data):
|
||||
def key_function(elem):
|
||||
key = elem[0]
|
||||
# Prioritizes certain keys when sorting.
|
||||
prio = {"version": 0, "projects": 1, "repo": 2, "hash": 3}.get(key, 99)
|
||||
return (prio, key)
|
||||
items = data.items()
|
||||
items.sort(key=key_function)
|
||||
return self.represent_mapping(u'tag:yaml.org,2002:map', items)
|
||||
|
||||
|
||||
yaml.add_representer(dict, represent_dict)
|
||||
|
||||
|
||||
# sourced from
|
||||
# http://stackoverflow.com/questions/25108581/python-yaml-dump-bad-indentation
|
||||
def yaml_dump(dump, indentSize=2):
|
||||
stream = StringIO(dump)
|
||||
out = StringIO()
|
||||
pat = re.compile(r'(\s*)([^:]*)(:*)')
|
||||
last = None
|
||||
|
||||
prefix = 0
|
||||
for s in stream:
|
||||
indent, key, colon = pat.match(s).groups()
|
||||
if indent == "" and key[0] != '-':
|
||||
prefix = 0
|
||||
if last:
|
||||
if len(last[0]) == len(indent) and last[2] == ':':
|
||||
if all([
|
||||
not last[1].startswith('-'),
|
||||
s.strip().startswith('-')]):
|
||||
prefix += indentSize
|
||||
out.write(" " * prefix + s)
|
||||
last = indent, key, colon
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the main application."""
|
||||
|
||||
# Setup argument parsing
|
||||
parser = argparse.ArgumentParser(
|
||||
description='release.yml producer',
|
||||
epilog='Licensed "Apache 2.0"')
|
||||
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
'--file',
|
||||
help='<Required> ansible-role-requirements.yml file location',
|
||||
default='ansible-role-requirements.yml'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-v',
|
||||
'--version',
|
||||
help='<Required> The release version to include in the output',
|
||||
required=True
|
||||
)
|
||||
|
||||
# Parse arguments
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read the ansible-role-requirements.yml file into memory
|
||||
with open(args.file, "r") as role_req_file:
|
||||
reqs = yaml.safe_load(role_req_file)
|
||||
|
||||
# Prepare the vars for output
|
||||
version = args.version
|
||||
projects = []
|
||||
|
||||
# Prepare the regex match
|
||||
regex = re.compile('^.*openstack/(ansible-hardening|openstack-ansible.*)$')
|
||||
|
||||
# Loop through the list of roles
|
||||
for role_data in reqs:
|
||||
# Only add OpenStack repositories to the release
|
||||
if regex.match(role_data['src']):
|
||||
# Prepare the repo release dict
|
||||
repo_release = {}
|
||||
# Figure out the repo from the git source
|
||||
repo = urlparse(role_data['src']).path.lstrip('/')
|
||||
# Assemble the dict
|
||||
repo_release['repo'] = repo
|
||||
repo_release['hash'] = role_data['version']
|
||||
# Add the dict to the projects list
|
||||
projects.append(repo_release.copy())
|
||||
|
||||
# Put the yaml content together
|
||||
releases = {'releases': [{'version': version, 'projects': projects}]}
|
||||
|
||||
# Product the YAML output for the resulting releases data
|
||||
output = yaml.dump(releases, default_flow_style=False)
|
||||
|
||||
# Print the output, formatted as expected
|
||||
print(yaml_dump(output))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -1,314 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2015, Rackspace US, Inc.
|
||||
# Copyright 2017, SUSE LINUX GmbH.
|
||||
#
|
||||
# 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.
|
||||
|
||||
###### HOOKS ########
|
||||
# The following hooks can be defined in the user scripts. All hooks accept the
|
||||
# following parameters:
|
||||
#
|
||||
# 1: repository name
|
||||
# 2: OpenStack service branch
|
||||
# 3: OSA branch
|
||||
# 4: repository address
|
||||
#
|
||||
#osa_pre_sync_hook: Actions to be performed before copying updated files to OSA OpenStack services repositories
|
||||
osa_pre_sync_hook() { true; }
|
||||
#osa_post_sync_hook: Actions to be performed after copying updated files to OSA OpenStack services repositories
|
||||
osa_post_sync_hook() { true; }
|
||||
|
||||
###### HELPER FUNCTIONS ######
|
||||
osa_helper_cleanup_files() {
|
||||
[[ $# > 0 ]] && rm -rf "${@}"
|
||||
}
|
||||
|
||||
osa_helper_clone_os_package() {
|
||||
local repo_name="${1}"
|
||||
local os_branch="${2}"
|
||||
local os_branch_sha"${3}"
|
||||
local repo_address="${4}"
|
||||
local os_repo_tmp_path="/tmp/os_${repo_name}"
|
||||
|
||||
osa_helper_cleanup_files ${os_repo_tmp_path}
|
||||
# Do a shallow clone of the OpenStack repo to work with
|
||||
if git clone --quiet --depth=10 --branch ${os_branch} --no-checkout --single-branch ${repo_address} ${os_repo_tmp_path}; then
|
||||
pushd ${os_repo_tmp_path} > /dev/null
|
||||
git checkout --quiet ${os_branch_sha}
|
||||
popd > /dev/null
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
osa_helper_clone_osa_role() {
|
||||
local repo_name="${1}"
|
||||
local osa_branch="${2}"
|
||||
local osa_repo_address="${3:-https://opendev.org/openstack/openstack-ansible-os_${repo_name}}"
|
||||
local osa_repo_tmp_path="/tmp/osa_${repo_name}"
|
||||
|
||||
osa_helper_cleanup_files ${osa_repo_tmp_path}
|
||||
# Do a shallow clone of the OSA repo to work with
|
||||
if git clone --quiet --depth=10 --branch ${osa_branch} --single-branch ${osa_repo_address} ${osa_repo_tmp_path}; then
|
||||
pushd ${osa_repo_tmp_path} > /dev/null
|
||||
git checkout --quiet origin/${osa_branch}
|
||||
popd > /dev/null
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
####### MAIN FUNCTIONS #######
|
||||
|
||||
#
|
||||
# Updates SHAs for OSA roles and OpenStack repo packages.
|
||||
#
|
||||
sync_roles_and_packages() {
|
||||
local repo_name repo_address branch_data branch_sha branch_entry osa_repo_tmp_path os_repo_tmp_path
|
||||
local os_branch="${1}"; shift
|
||||
local osa_branch="${1}"; shift
|
||||
local service_file="${1}"; shift
|
||||
local openstack_service_list="$@"
|
||||
local osa_repo_address="https://opendev.org/openstack/openstack-ansible-os_${repo_name}"
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
# Iterate through the service file
|
||||
for repo in $(grep 'git_repo\:' ${service_file}); do
|
||||
# Set the repo name
|
||||
repo_name=$(echo "${repo}" | sed 's/_git_repo\:.*//g')
|
||||
local osa_repo_tmp_path="/tmp/osa_${repo_name}"
|
||||
local os_repo_tmp_path="/tmp/os_${repo_name}"
|
||||
|
||||
echo -e "\nInspecting ${repo}..."
|
||||
|
||||
# Set the repo address
|
||||
repo_address=$(echo ${repo} | awk '{print $2}')
|
||||
|
||||
# Get the branch data
|
||||
branch_data=$(git ls-remote ${repo_address} | grep "${os_branch}$")
|
||||
|
||||
# If there is no branch data, move to the next role
|
||||
[ -z "${branch_data}" ] && continue
|
||||
|
||||
# Set the branch sha for the head of the branch
|
||||
branch_sha=$(echo "${branch_data}" | awk '{print $1}')
|
||||
|
||||
# Set the branch entry
|
||||
branch_entry="${branch_sha} # HEAD of \"$os_branch\" as of $(date +%d.%m.%Y)"
|
||||
|
||||
# Write the branch entry into the repo_packages file
|
||||
sed -i.bak "s|${repo_name}_git_install_branch:.*|${repo_name}_git_install_branch: $branch_entry|" ${service_file}
|
||||
|
||||
# If the repo is not in the specified list, then move to the next role
|
||||
! [[ "${openstack_service_list}" =~ "${repo_name}" ]] && continue
|
||||
|
||||
if osa_helper_clone_os_package ${repo_name} ${os_branch} ${branch_sha} ${repo_address}; then
|
||||
if osa_helper_clone_osa_role ${repo_name} ${osa_branch}; then
|
||||
|
||||
# pre-sync user hook
|
||||
osa_pre_sync_hook ${repo_name} ${os_branch} ${osa_branch} ${repo_address}
|
||||
|
||||
# We have implemented tooling to dynamically fetch the
|
||||
# api-paste and other static/template files from these
|
||||
# repositories, so skip trying to update their templates
|
||||
# and static files.
|
||||
local static_file_repo_skip_list=( ceilometer gnocchi keystone )
|
||||
|
||||
# Check if this repo is in the static file skip list
|
||||
local skip_this_repo="no"
|
||||
for skip_list_item in "${static_file_repo_skip_list[@]}"; do
|
||||
if [[ "${repo_name}" == "${skip_list_item}" ]]; then
|
||||
skip_this_repo="yes"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "${skip_this_repo}" != "yes" ]] && [[ -e "${os_repo_tmp_path}/etc" ]]; then
|
||||
# Update the policy files
|
||||
find ${os_repo_tmp_path}/etc -name "policy.json" -exec \
|
||||
cp {} "${osa_repo_tmp_path}/templates/policy.json.j2" \;
|
||||
|
||||
# Tweak the paste files for any hmac key entries
|
||||
find ${os_repo_tmp_path}/etc -name "*[_-]paste.ini" -exec \
|
||||
sed -i.bak "s|hmac_keys = SECRET_KEY|hmac_keys = {{ ${repo_name}_profiler_hmac_key }}|" {} \;
|
||||
|
||||
# Tweak the barbican paste file to support keystone auth
|
||||
if [[ "${repo_name}" == "barbican" ]]; then
|
||||
find ${os_repo_tmp_path}/etc -name "*[_-]paste.ini" -exec \
|
||||
sed -i.bak "s|\/v1\: barbican-api-keystone|\/v1\: {{ (barbican_keystone_auth \| bool) \| ternary('barbican-api-keystone', 'barbican_api') }}|" {} \;
|
||||
fi
|
||||
|
||||
# Tweak the gnocchi paste file to support keystone auth
|
||||
if [[ "${repo_name}" == "gnocchi" ]]; then
|
||||
find ${os_repo_tmp_path}/etc -name "*[_-]paste.ini" -exec \
|
||||
sed -i.bak "s|pipeline = gnocchi+noauth|pipeline = {{ (gnocchi_keystone_auth \| bool) \| ternary('gnocchi+auth', 'gnocchi+noauth') }}|" {} \;
|
||||
fi
|
||||
|
||||
# Update the paste files
|
||||
find ${os_repo_tmp_path}/etc -name "*[_-]paste.ini" -exec \
|
||||
bash -c "name=\"{}\"; cp \${name} \"${osa_repo_tmp_path}/templates/\$(basename \${name}).j2\"" \;
|
||||
|
||||
# Update the yaml files for Heat
|
||||
if [[ "${repo_name}" == "heat" ]]; then
|
||||
find ${os_repo_tmp_path}/etc -name "*.yaml" -exec \
|
||||
bash -c "name=\"{}\"; cp \${name} \"${osa_repo_tmp_path}/templates/\$(echo \${name} | rev | cut -sd / -f -2 | rev).j2\"" \;
|
||||
fi
|
||||
fi
|
||||
|
||||
# We have to check for rootwrap files in *all* service repositories
|
||||
# as we have no dynamic way of fetching them at this stage.
|
||||
if [[ -e "${os_repo_tmp_path}/etc" ]]; then
|
||||
|
||||
# Tweak the rootwrap conf filters_path (for neutron only)
|
||||
if [[ "${repo_name}" == "neutron" ]]; then
|
||||
find ${os_repo_tmp_path}/etc -name "rootwrap.conf" -exec \
|
||||
sed -i.bak "s|filters_path=/etc/neutron|filters_path={{ ${repo_name}_conf_dir }}|" {} \;
|
||||
fi
|
||||
|
||||
# Tweak the rootwrap conf exec_dirs
|
||||
find ${os_repo_tmp_path}/etc -name "rootwrap.conf" -exec \
|
||||
sed -i.bak "s|exec_dirs=|exec_dirs={{ ${repo_name}_bin }},|" {} \;
|
||||
|
||||
# Update the rootwrap conf files
|
||||
find ${os_repo_tmp_path}/etc -name "rootwrap.conf" -exec \
|
||||
cp {} "${osa_repo_tmp_path}/templates/rootwrap.conf.j2" \;
|
||||
|
||||
# Update the rootwrap filters
|
||||
mkdir -p ${osa_repo_tmp_path}/files/rootwrap.d
|
||||
find ${os_repo_tmp_path}/etc -name "*.filters" -exec \
|
||||
bash -c "name=\"{}\"; cp \${name} \"${osa_repo_tmp_path}/files/rootwrap.d/\$(basename \${name})\"" \;
|
||||
|
||||
fi
|
||||
|
||||
# post-sync user hook
|
||||
osa_post_sync_hook ${repo_name} ${os_branch} ${osa_branch} ${repo_address}
|
||||
|
||||
osa_helper_cleanup_files ${osa_repo_tmp_path} ${os_repo_tmp_path}
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "Processed $repo_name @ $branch_entry\n"
|
||||
|
||||
done
|
||||
|
||||
unset IFS
|
||||
}
|
||||
|
||||
#
|
||||
# Updates global requirement pins for pip, setuptools and wheel
|
||||
#
|
||||
update_pip_options() {
|
||||
PIP_CURRENT_OPTIONS=$(./scripts/get-pypi-pkg-version.py -p pip setuptools wheel -l horizontal)
|
||||
|
||||
for pin in ${PIP_CURRENT_OPTIONS}; do
|
||||
sed -i.bak "s|^$(echo ${pin} | cut -f1 -d=).*|${pin}|" global-requirement-pins.txt
|
||||
done
|
||||
|
||||
echo "Updated global requirement pins"
|
||||
}
|
||||
|
||||
#
|
||||
# Updates ansible-role-requirements file SHAs
|
||||
#
|
||||
update_ansible_role_requirements() {
|
||||
local role_name role_version osa_repo_tmp_path role_git_sources current_source_dir
|
||||
local osa_branch=${1}
|
||||
local pre_release=${2}
|
||||
local force_master=${3}
|
||||
current_source_dir="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
|
||||
|
||||
# Update the ansible-role-requirements.yml file
|
||||
if [ "${osa_branch}" != "master" ] || \
|
||||
[ "${pre_release}" == "true" ] || \
|
||||
[ "${force_master}" == "true" ]; then
|
||||
echo "Updating ansible-role-requirements.yml"
|
||||
|
||||
if [ "${pre_release}" == "true" ]; then
|
||||
role_git_sources=$(awk '/src: .*/ {print $2}' ansible-role-requirements.yml)
|
||||
else
|
||||
role_git_sources=$(awk '/src: .*\/openstack\// {print $2}' ansible-role-requirements.yml)
|
||||
fi
|
||||
|
||||
# Loop through each of the role git sources, only looking for openstack roles
|
||||
for role_src in ${role_git_sources}; do
|
||||
|
||||
# Determine the role's name
|
||||
role_name=$(sed 's/^[ \t-]*//' ansible-role-requirements.yml | awk '/src: / || /name: / {print $2}' | grep -B1 "${role_src}" | head -n 1)
|
||||
echo "... updating ${role_name}"
|
||||
|
||||
# If the role_src is NOT from opendev.org, try to get a tag first unless we are working on master
|
||||
if [[ ${role_src} != *"opendev.org"* ]] && [[ "${force_master}" != "true" ]]; then
|
||||
role_version=$(git ls-remote --tags ${role_src} | awk '{print $2}' | grep -v '{}' | cut -d/ -f 3 | sort --version-sort | tail -n 1)
|
||||
fi
|
||||
|
||||
# Grab the latest SHA that matches the specified branch
|
||||
if [[ -z "${role_version}" ]]; then
|
||||
role_version=$(git ls-remote ${role_src} | grep "${osa_branch}$" | awk '{print $1}')
|
||||
fi
|
||||
|
||||
# If we are forcing master and we still don't have a role_version defined, then we need
|
||||
# to fallback to master branch
|
||||
if [[ -z "${role_version}" ]] && [[ "${force_master}" == "true" ]]; then
|
||||
role_version=$(git ls-remote ${role_src} | grep /master$ | awk '{print $1}')
|
||||
fi
|
||||
|
||||
# For OSA roles, get the release notes
|
||||
if [[ ${role_src} == *"opendev.org"* ]]; then
|
||||
local osa_repo_tmp_path="/tmp/osa_${role_name}"
|
||||
|
||||
osa_helper_clone_osa_role $role_name $osa_branch $role_src
|
||||
|
||||
# If there are releasenotes to copy, then copy them
|
||||
if $(ls -1 ${osa_repo_tmp_path}/releasenotes/notes/*.yaml > /dev/null 2>&1); then
|
||||
rsync -aq ${osa_repo_tmp_path}/releasenotes/notes/*.yaml releasenotes/notes/
|
||||
fi
|
||||
|
||||
osa_helper_cleanup_files $osa_repo_tmp_path
|
||||
fi
|
||||
|
||||
# Now use the information we have to update the ansible-role-requirements file
|
||||
"$current_source_dir/ansible-role-requirements-editor.py" -f ansible-role-requirements.yml -n "${role_name}" -v "${role_version}"
|
||||
|
||||
unset role_version
|
||||
done
|
||||
echo "Completed updating ansible-role-requirements.yml"
|
||||
else
|
||||
echo "Skipping the ansible-role-requirements.yml update as we're working on the master branch"
|
||||
fi
|
||||
}
|
||||
|
||||
update_release_version() {
|
||||
local osa_branch=${1}
|
||||
local service_file=${2}
|
||||
|
||||
# Update the release version in group_vars/all/all.yml
|
||||
# We don't want to be doing this for the master branch and we only want
|
||||
# to do it once, so we key off of a specific repo source file name.
|
||||
if [[ "${osa_branch}" != "master" ]] && [[ "${service_file}" == "playbooks/defaults/repo_packages/openstack_services.yml" ]]; then
|
||||
|
||||
echo "Updating the release version..."
|
||||
currentversion=$(awk '/openstack_release:/ {print $2}' group_vars/all/all.yml)
|
||||
|
||||
# Extract the required version info
|
||||
major_version=$( echo ${currentversion} | cut -d. -f1 )
|
||||
minor_version=$( echo ${currentversion} | cut -d. -f2 )
|
||||
patch_version=$( echo ${currentversion} | cut -d. -f3 )
|
||||
|
||||
# increment the patch version
|
||||
patch_version=$(( patch_version + 1 ))
|
||||
|
||||
sed -i .bak "s/${currentversion}/${major_version}.${minor_version}.${patch_version}/" group_vars/all/all.yml
|
||||
else
|
||||
echo "Skipping the release version update as we're working on the master branch"
|
||||
fi
|
||||
}
|
@@ -1,142 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2015, Rackspace US, Inc.
|
||||
# Copyright 2017, SUSE LINUX GmbH.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# This script was created to rapidly interate through a repo_package file
|
||||
# that contains git sources and set the various repositories inside to
|
||||
# the head of given branch via the SHA. This makes it possible to update
|
||||
# all of the services that we support in an "automated" fashion.
|
||||
|
||||
OS_BRANCH=${OS_BRANCH:-"master"}
|
||||
OSA_BRANCH=${OSA_BRANCH:-"$OS_BRANCH"}
|
||||
SERVICE_FILE=${SERVICE_FILE:-"playbooks/defaults/repo_packages/openstack_services.yml"}
|
||||
OPENSTACK_SERVICE_LIST=${OPENSTACK_SERVICE_LIST:-""}
|
||||
PRE_RELEASE=${PRE_RELEASE:-"false"}
|
||||
FORCE_MASTER=${FORCE_MASTER:-"false"}
|
||||
|
||||
# Here we inspect the service file to compile the list of repositories
|
||||
# we're interested in inspecting for the purpose of doing in-repo updates
|
||||
# of static files that we template/copy when doing installs.
|
||||
#
|
||||
# If a predefined list is provided, skip all this.
|
||||
if [[ -z ${OPENSTACK_SERVICE_LIST} ]]; then
|
||||
# Setup an array of all the repositories in the
|
||||
# service file provided.
|
||||
OPENSTACK_REPO_LIST=( $(grep 'git_repo\:' ${SERVICE_FILE} | awk -F '/' '{ print $NF }') )
|
||||
|
||||
# Define the repositories to skip in an array.
|
||||
# These items are removed as they are not service projects
|
||||
# and therefore do not have policy/api-paste/etc files.
|
||||
OPENSTACK_REPO_SKIP_LIST=( requirements swift3 )
|
||||
|
||||
# Define the skip regex for any additional items to remove.
|
||||
# Items with a '-' are removed as those repositories are
|
||||
# typically extensions/drivers/dashboards and therefore
|
||||
# do not include policy/api-paste/etc files.
|
||||
OPENSTACK_REPO_SKIP_REGEX='.*-.*'
|
||||
|
||||
# Loop through each item and if it does not match
|
||||
# an item in the SKIP_LIST or match the SKIP_REGEX
|
||||
# then add it to the OPENSTACK_SERVICE_LIST string.
|
||||
for item_to_check in "${OPENSTACK_REPO_LIST[@]}"; do
|
||||
add_item="yes"
|
||||
if [[ ! "${item_to_check}" =~ ${OPENSTACK_REPO_SKIP_REGEX} ]]; then
|
||||
for item_to_delete in "${OPENSTACK_REPO_SKIP_LIST[@]}"; do
|
||||
if [[ "${item_to_delete}" == "${item_to_check}" ]]; then
|
||||
add_item="no"
|
||||
fi
|
||||
done
|
||||
else
|
||||
add_item="no"
|
||||
fi
|
||||
if [[ "${add_item}" == "yes" ]]; then
|
||||
OPENSTACK_SERVICE_LIST="${OPENSTACK_SERVICE_LIST} ${item_to_check}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
source scripts/sources-branch-updater-lib.sh || { echo "Failed to source updater library"; exit 1; }
|
||||
|
||||
if echo "$@" | grep -e '-h' -e '--help';then
|
||||
echo "
|
||||
Options:
|
||||
-b|--openstack-branch (name of OpenStack branch, eg: stable/newton)
|
||||
-o|--osa-branch (name of the OSA branch, eg: stable/newton)
|
||||
-s|--service-file (path to service file to parse)
|
||||
"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Provide some CLI options
|
||||
while [[ $# > 1 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-b|--openstack-branch)
|
||||
OS_BRANCH="$2"
|
||||
shift
|
||||
;;
|
||||
-o|--osa-branch)
|
||||
OSA_BRANCH="$2"
|
||||
shift
|
||||
;;
|
||||
-s|--service-file)
|
||||
SERVICE_FILE="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
commit_changes() {
|
||||
local repo_name="${1}"
|
||||
local osa_repo_tmp_path="/tmp/osa_${repo_name}"
|
||||
|
||||
# Switch into the OSA git directory to work with it
|
||||
pushd ${osa_repo_tmp_path} > /dev/null
|
||||
|
||||
# Check for changed files
|
||||
git_changed=$(git status --porcelain | wc -l)
|
||||
# Check for untracked files
|
||||
git_untracked=$(git ls-files --other --exclude-standard --directory | wc -l)
|
||||
if [ ${git_untracked} -gt 0 ]; then
|
||||
# If there are untracked files, ensure that the commit message includes
|
||||
# a WIP prefix so that the patch is revised in more detail.
|
||||
git_msg_prefix="[New files - needs update] "
|
||||
else
|
||||
git_msg_prefix=""
|
||||
fi
|
||||
|
||||
# If any files have changed, submit a patch including the changes
|
||||
if [ ${git_changed} -gt 0 ]; then
|
||||
git checkout -b sha-update
|
||||
git review -s > /dev/null
|
||||
git add --all
|
||||
git commit -a -m "${git_msg_prefix}Update paste, policy and rootwrap configurations $(date +%Y-%m-%d)" --quiet
|
||||
git review > /dev/null
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
osa_post_sync_hook() { commit_changes "$@"; }
|
||||
|
||||
sync_roles_and_packages ${OS_BRANCH} ${OSA_BRANCH} ${SERVICE_FILE} ${OPENSTACK_SERVICE_LIST}
|
||||
|
||||
update_pip_options
|
||||
|
||||
update_ansible_role_requirements ${OSA_BRANCH} ${PRE_RELEASE} ${FORCE_MASTER}
|
||||
|
||||
update_release_version ${OSA_BRANCH} ${SERVICE_FILE}
|
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2014, Rackspace US, 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.
|
||||
|
||||
# What this script is for:
|
||||
# This script updates the various "openstack_release" variables The
|
||||
# purpose of this script is to eliminate error when updating the released
|
||||
# versions.
|
||||
|
||||
if echo "$@" | grep -e '-h' -e '--help' || [ -z "${2}" ];then
|
||||
echo "
|
||||
Options:
|
||||
-r|--revision (name/id of revision)
|
||||
"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Provide some CLI options
|
||||
while [[ $# > 1 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-r|--revision)
|
||||
REVISION="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
sed -i.bak "s/^openstack_release\:.*/openstack_release\: ${REVISION}/" group_vars/all/all.yml
|
Reference in New Issue
Block a user