project-name: github-ciman
+- project:
+ name: gerrit-openstack-jobs
+ jobs:
+ - gerrit-openstack-cron
+
+ project-name: gerrit-ciman
+
+- project:
+ name: github-openstack-jobs
+ jobs:
+ - github-openstack-cron
+
+ project-name: github-ciman
+
+
- project:
name: gerrit-packer-jobs
jobs:
:project-pattern: The ANT based pattern for Gerrit Trigger to choose which
projects to trigger job against. (default: '**')
+.. _gjjb-openstack-cron:
+
+OpenStack Cron
+--------------
+
+Cron job that runs regularly to perform periodic tasks against OpenStack.
+
+This job requires a Config File Provider file named ``clouds-yaml`` available
+containing the credentials for the cloud.
+
+:Template Names:
+ - {project-name}-openstack-cron
+ - gerrit-openstack-cron
+ - github-openstack-cron
+
+:Required parameters:
+
+ :build-node: The node to run build on.
+ :jenkins-ssh-credential: Credential to use for SSH. (Generally should
+ be configured in defaults.yaml)
+
+:Optional parameters:
+
+ :branch: Git branch to fetch for the build. (default: master)
+ :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
+ :build-timeout: Timeout in minutes before aborting build. (default: 90)
+ :cron: Time when the packer image should be rebuilt (default: @daily)
+ :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
+ :openstack-cloud: OS_CLOUD setting to pass to openstack client.
+ (default: vex)
+ :stream: Keyword that can be used to represent a release code-name.
+ Often the same as the branch. (default: master)
+ :submodule-recursive: Whether to checkout submodules recursively.
+ (default: true)
+
.. _gjjb-packer-merge:
Packer Merge
white-list-target-branches:
- '{branch}'
+##################
+# OPENSTACK CRON #
+##################
+
+- lf_openstack_cron: &lf_openstack_cron
+ name: lf-openstack-cron
+
+ ######################
+ # Default parameters #
+ ######################
+
+ branch: master
+ build-days-to-keep: 7
+ build-timeout: 10
+ cron: '@daily'
+ git-url: '$GIT_URL/$PROJECT'
+ github-url: 'https://github.com'
+ openstack-cloud: vex
+ stream: master
+
+ #####################
+ # Job Configuration #
+ #####################
+
+ project-type: freestyle
+ node: '{build-node}'
+ concurrent: false
+
+ properties:
+ - lf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+
+ parameters:
+ - lf-infra-parameters:
+ project: '{project}'
+ stream: '{stream}'
+ branch: '{branch}'
+ lftools-version: '{lftools-version}'
+
+ wrappers:
+ - lf-infra-wrappers:
+ build-timeout: '{build-timeout}'
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+ # Listed after to override openstack-infra-wrappers clouds.yaml definition
+ - config-file-provider:
+ files:
+ - file-id: clouds-yaml
+ target: '$HOME/.config/openstack/clouds.yaml'
+ - file-id: npmrc
+ target: '$HOME/.npmrc'
+ - file-id: pipconf
+ target: '$HOME/.config/pip/pip.conf'
+
+ triggers:
+ - timed: '{obj:cron}'
+
+ builders:
+ - inject:
+ properties-content: OS_CLOUD={openstack-cloud}
+ - shell: !include-raw-escape: ../shell/openstack-install.sh
+ - shell: !include-raw-escape: ../shell/openstack-protect-in-use-images.sh
+
+ publishers:
+ - lf-infra-publish
+
+- job-template:
+ name: '{project-name}-openstack-cron'
+ id: gerrit-openstack-cron
+ <<: *lf_openstack_cron
+
+ scm:
+ - lf-infra-gerrit-scm:
+ git-url: '{git-url}'
+ refspec: 'refs/heads/{branch}'
+ branch: '{branch}'
+ submodule-recursive: true
+ choosing-strategy: default
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+- job-template:
+ name: '{project-name}-openstack-cron'
+ id: github-openstack-cron
+ <<: *lf_openstack_cron
+
+ scm:
+ - lf-infra-github-scm:
+ url: '{git-clone-url}{github-org}/{project}'
+ refspec: ''
+ branch: 'refs/heads/{branch}'
+ submodule-recursive: true
+ choosing-strategy: default
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
################
# Packer Merge #
################
--- /dev/null
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Install the openstack cli
+echo "---> Install openstack cli"
+
+set -eux -o pipefail
+
+pip install --user --quiet --upgrade "pip<10.0.0" setuptools
+pip install --user --quiet --upgrade python-openstackclient python-heatclient
+pip freeze
--- /dev/null
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017, 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Checks the image "protected" value and set "True" marker
+#
+# The script searches the ciman repo for the images presently used and ensures
+# the protection setting is set for those images to prevent the image from
+# getting purged by the image cleanup script.
+# This script assumes images prefixed with the string "ZZCI - " are ci-managed
+# images.
+echo "---> Protect in-use images"
+
+os_cloud="${OS_CLOUD:-vex}"
+
+set -eu -o pipefail
+
+declare -a images
+declare -a cfg_images
+declare -a yaml_images
+readarray -t cfg_images <<< "$(grep -r IMAGE_NAME --include \*.cfg \
+ | awk -F'=' '{print $2}' | sort -u)"
+readarray -t yaml_images <<< "$(grep -r 'ZZCI - ' --include \*.yaml \
+ | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)"
+mapfile -t images < <(for R in "${cfg_images[@]}" "${yaml_images[@]}" ; do echo "$R" ; done | sort -u)
+
+
+for image in "${images[@]}"; do
+ os_image_protected=$(openstack --os-cloud "$os_cloud" \
+ image show "$image" -f value -c protected)
+ echo "Protected setting for $image: $os_image_protected"
+
+ if [[ $os_image_protected != True ]]; then
+ echo " Image NOT set as protected, changing the protected value."
+ openstack --os-cloud "$os_cloud" image set --protected "$image"
+ fi
+done