├── bot ├── templates │ ├── Caddyfile.j2 │ ├── clouds.yaml.j2 │ ├── cireport.timer.j2 │ ├── cireport.service.j2 │ ├── clean-ci-resources.timer.j2 │ ├── secure.yaml.j2 │ └── clean-ci-resources.service.j2 ├── openstack-credentials.sh ├── inventory.yaml ├── cireport.yaml └── clean-ci-resources.yaml ├── .gitignore ├── pull-artifacts ├── Makefile ├── hack └── get-terraform.sh ├── get-rhcos-image.sh ├── clean-ci-resources.sh ├── list-clusters ├── report.sh ├── cluster_config.sh.example ├── refresh_rhcos.sh ├── stale ├── docs └── README.adoc ├── README.md ├── destroy_cluster.sh ├── populate_mirror.sh ├── ci-dns ├── create_ci_dns.sh ├── CI-DNS.yml └── CI-DNS.ign ├── run_ocp.sh ├── server.sh └── LICENSE /bot/templates/Caddyfile.j2: -------------------------------------------------------------------------------- 1 | http://localhost:9097 { 2 | root * /var/clean-ci-resources 3 | file_server 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore other user's cluster configs 2 | *cluster_config.sh 3 | 4 | # ignore cluster artifacts 5 | /clusters 6 | 7 | # ignore cloud credentials 8 | /bot/cloud-credentials.json 9 | -------------------------------------------------------------------------------- /bot/templates/clouds.yaml.j2: -------------------------------------------------------------------------------- 1 | clouds: 2 | {% for cloud in clouds %} 3 | 4 | {{ cloud.name }}: 5 | auth: 6 | auth_url: '{{ cloud.auth_url }}' 7 | identity_api_version: 3 8 | {% endfor %} 9 | -------------------------------------------------------------------------------- /bot/templates/cireport.timer.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=cireport timer 3 | 4 | [Timer] 5 | Unit=cireport.service 6 | OnCalendar={{ cireport_timer_oncalendar }} 7 | Persistent=false 8 | 9 | [Install] 10 | WantedBy=timers.target 11 | -------------------------------------------------------------------------------- /bot/templates/cireport.service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=cireport 3 | 4 | [Service] 5 | User=cireport 6 | Type=simple 7 | Environment=CIREPORT_USER=shiftstack-bot 8 | WorkingDirectory=/home/cireport/gazelle 9 | ExecStart=/usr/bin/cireport 10 | -------------------------------------------------------------------------------- /bot/templates/clean-ci-resources.timer.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=clean-ci-resources timer 3 | 4 | [Timer] 5 | Unit=clean-ci-resources.service 6 | OnCalendar={{ ci_clean_timer_oncalendar }} 7 | Persistent=false 8 | 9 | [Install] 10 | WantedBy=timers.target 11 | -------------------------------------------------------------------------------- /bot/templates/secure.yaml.j2: -------------------------------------------------------------------------------- 1 | clouds: 2 | {% for cloud in clouds %} 3 | 4 | {{ cloud.name }}: 5 | auth: 6 | application_credential_id: '{{ cloud.credential_id }}' 7 | application_credential_secret: '{{ cloud.credential_secret }}' 8 | auth_type: "v3applicationcredential" 9 | {% endfor %} 10 | -------------------------------------------------------------------------------- /bot/templates/clean-ci-resources.service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=clean-ci-resources 3 | 4 | [Service] 5 | User=clean-ci-resources 6 | Environment=log_cloud={{ ci_clean_log_cloud }} 7 | Environment=log_container={{ ci_clean_log_container }} 8 | Environment=metrics_file=/var/clean-ci-resources/metrics 9 | WorkingDirectory=/home/clean-ci-resources/shiftstack-ci 10 | ExecStart=/usr/bin/env bash /home/clean-ci-resources/shiftstack-ci/report.sh -c "$log_cloud" -o "$log_container" -m "$metrics_file" moc-ci vexxhost 11 | -------------------------------------------------------------------------------- /pull-artifacts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuo pipefail 4 | 5 | if [[ "${1:-}" == '' ]]; then 6 | >&2 echo "Usage: $0 " 7 | exit 1 8 | fi 9 | 10 | to_job_name() { 11 | trimmed_left="${1#*/origin-ci-test/}" 12 | printf '%s' "${trimmed_left%/artifacts/*}" 13 | } 14 | 15 | to_job_number() { 16 | name="$(to_job_name "$1")" 17 | trimmed_right="${name%/}" 18 | printf '%s' "${trimmed_right##*/}" 19 | 20 | } 21 | 22 | job_name="$(to_job_name "$1")" 23 | job_number="$(to_job_number "$1")" 24 | 25 | echo "Creating directory $job_number" 26 | mkdir "$job_number" 27 | 28 | echo "Syncing origin-ci-test/$job_name" 29 | gsutil -m rsync -r "gs://origin-ci-test/${job_name}" "$job_number" 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | KEY_NAME ?= $(shell whoami) 3 | 4 | shiftstack-bot: shiftstack-bot-clean-ci-resources shiftstack-bot-cireport 5 | .PHONY: shiftstack-bot 6 | 7 | shiftstack-bot-clean-ci-resources: bot/cloud-credentials.json 8 | ansible-playbook -i bot/inventory.yaml bot/clean-ci-resources.yaml 9 | .PHONY: shiftstack-bot-clean-ci-resources 10 | 11 | shiftstack-bot-cireport: 12 | ansible-playbook -i bot/inventory.yaml bot/cireport.yaml 13 | .PHONY: shiftstack-bot-cireport 14 | 15 | bot/cloud-credentials.json: 16 | bot/openstack-credentials.sh vexxhost moc-ci moc psi > $@ 17 | 18 | server: 19 | OS_CLOUD=psi ./server.sh -f ci.m1.micro -i Fedora-Cloud-Base-33 -e provider_net_shared_3 -k $(KEY_NAME) -p shiftstack-bot 20 | .PHONY: server 21 | -------------------------------------------------------------------------------- /bot/openstack-credentials.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuo pipefail 4 | 5 | # * Creates application credentials for all clouds in the available clouds.yaml 6 | # * Outputs them in the format consumable by the Ansible playbook: 7 | # { "clouds": [{ "name": "", "auth_url": "", "credential_id": "", "credential_secret": ""}]} 8 | for cloud in "$@"; do 9 | openstack --os-cloud "$cloud" application credential create shiftstack-bot -f json -c id -c secret \ 10 | | jq '{"credential_id": .id, "credential_secret": .secret} + {"name": "'"$cloud"'"}' \ 11 | | jq '.+{"auth_url": "'"$(openstack --os-cloud "$cloud" catalog show identity -f json | jq -r '.endpoints[] | select(.interface=="public").url + "/v3"')"'"}' 12 | done | jq -sc '. | {"clouds": .}' 13 | -------------------------------------------------------------------------------- /bot/inventory.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | all: 4 | hosts: 5 | shiftstack-bot: 6 | ansible_python_interpreter: "{{ansible_playbook_python}}" 7 | 8 | ci_clean_log_cloud: 'psi' 9 | ci_clean_log_container: 'shiftstack-bot' 10 | ci_clean_timer_oncalendar: 'hourly' 11 | 12 | openshift_install_src: 'https://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/latest-4.8/openshift-install-linux.tar.gz' 13 | 14 | cireport_timer_oncalendar: 'hourly' 15 | cireport_src: 'https://github.com/shiftstack/gazelle/releases/download/v0.1/cireport' 16 | cireport_checksum: 'sha256:235a8626f24fd70be7b5fd694093f087b89ae0073bad4407cc3d8f184661b169' 17 | cireport_local_credentials_path: '~/code/src/github.com/shiftstack/gazelle/credentials.json' 18 | cireport_local_token_path: '~/code/src/github.com/shiftstack/gazelle/token.json' 19 | -------------------------------------------------------------------------------- /hack/get-terraform.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | have() { 4 | command -v "${@}" >/dev/null 2>/dev/null 5 | } 6 | 7 | 8 | OS=linux 9 | ARCH=amd64 10 | FUNZIP="${FUNZIP:-funzip}" 11 | if ! have "${FUNZIP}" 12 | then 13 | if have gunzip 14 | then 15 | FUNZIP=gunzip 16 | else 17 | command -V "${FUNZIP}" 18 | exit 1 19 | fi 20 | fi && 21 | if have go 22 | then 23 | OS="$(go env GOOS)" && 24 | ARCH="$(go env GOARCH)" 25 | fi && 26 | 27 | # TODO get versions from openshift-installer toml files 28 | TERRAFORM_VERSION="0.12.0-rc1" && 29 | TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${OS}_${ARCH}.zip" && 30 | echo "pulling ${TERRAFORM_URL}" >&2 && 31 | cd "$(go env GOPATH)" && 32 | mkdir -p bin && 33 | curl -L "${TERRAFORM_URL}" | "${FUNZIP}" >bin/terraform && 34 | chmod +x bin/terraform 35 | 36 | go get -d github.com/terraform-providers/terraform-provider-openstack/ 37 | cd "$(go env GOPATH)/src/github.com/terraform-providers/terraform-provider-openstack/" 38 | git checkout b1406b8e4894faad993aff786f0bb50bfec8e281 39 | go get github.com/terraform-providers/terraform-provider-openstack/ 40 | -------------------------------------------------------------------------------- /bot/cireport.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | 5 | tasks: 6 | - name: 'Add the cireport user' 7 | become: yes 8 | user: 9 | name: cireport 10 | 11 | - name: 'Create a directory for cireport' 12 | become: yes 13 | become_user: cireport 14 | file: 15 | name: /home/cireport/gazelle 16 | state: directory 17 | 18 | - name: 'Copy local cireport credentials' 19 | become: yes 20 | become_user: cireport 21 | copy: 22 | src: '{{ cireport_local_credentials_path }}' 23 | dest: /home/cireport/gazelle/ 24 | 25 | - name: 'Copy local cireport token' 26 | become: yes 27 | become_user: cireport 28 | copy: 29 | src: '{{ cireport_local_token_path }}' 30 | dest: /home/cireport/gazelle/ 31 | 32 | - name: 'Get cireport' 33 | become: yes 34 | get_url: 35 | url: '{{ cireport_src }}' 36 | checksum: '{{ cireport_checksum }}' 37 | dest: /usr/bin/cireport 38 | mode: 0755 39 | 40 | - name: 'Create the systemd service for cireport' 41 | become: yes 42 | template: 43 | src: templates/cireport.service.j2 44 | dest: /lib/systemd/system/cireport.service 45 | 46 | - name: 'Create the systemd timer for cireport' 47 | become: yes 48 | template: 49 | src: templates/cireport.timer.j2 50 | dest: /lib/systemd/system/cireport.timer 51 | 52 | - name: 'Enable the cireport timer' 53 | become: yes 54 | systemd: 55 | name: cireport.timer 56 | enabled: yes 57 | state: started 58 | -------------------------------------------------------------------------------- /get-rhcos-image.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | BRANCH=master 5 | while [[ $# -gt 0 ]]; do 6 | case "$1" in 7 | -b|--branch) 8 | BRANCH=$2 9 | shift 2 10 | ;; 11 | -g|--gunzip) 12 | GUNZIP=true 13 | shift 14 | ;; 15 | -i|--info) 16 | INFO=true 17 | shift 18 | ;; 19 | -f|--outputfile) 20 | OUTPUTFILE=$2 21 | shift 2 22 | ;; 23 | *) 24 | break 25 | ;; 26 | esac 27 | done 28 | IMAGE_NAME="rhcos-$BRANCH" 29 | if [ $BRANCH == "master" ]; then 30 | REAL_BRANCH_NAME="master" 31 | else 32 | REAL_BRANCH_NAME="release-$BRANCH" 33 | fi 34 | 35 | IMAGE_SOURCE=https://raw.githubusercontent.com/openshift/installer/${REAL_BRANCH_NAME}/data/data/rhcos.json 36 | 37 | echo "Looking for $REAL_BRANCH_NAME in $IMAGE_SOURCE" 38 | set +e 39 | IMAGE_URL="$(curl --silent $IMAGE_SOURCE | jq --raw-output '.baseURI + .images.openstack.path')" 40 | if [ $? -ne 0 ]; then 41 | echo "Failed to find $REAL_BRANCH_NAME" 42 | exit 1 43 | fi 44 | set -e 45 | echo "RHCOS for $REAL_BRANCH_NAME available at:" 46 | echo "$IMAGE_URL" 47 | 48 | if [[ ! -z ${INFO+x} ]]; then 49 | exit 0 50 | fi 51 | 52 | echo "Downloading RHCOS image for $REAL_BRANCH_NAME" 53 | curl --insecure --compressed -L -O "$IMAGE_URL" 54 | 55 | IMAGE_NAME=$(echo "${IMAGE_URL##*/}") 56 | 57 | if [ ! -z ${GUNZIP+x} ]; then 58 | gzip -l $IMAGE_NAME >/dev/null 2>&1 59 | # Lets check to see if file is compressed with gzip 60 | # and uncompress it if so 61 | if [[ $? -eq 0 ]] 62 | then 63 | echo "$IMAGE_NAME is compressed. Expanding..." 64 | gunzip -f $IMAGE_NAME 65 | IMAGE_NAME="${IMAGE_NAME%.gz}" 66 | fi 67 | fi 68 | 69 | # Save image with user specified name. 70 | if [[ ! -z ${OUTPUTFILE+x} ]]; then 71 | mv $IMAGE_NAME ${OUTPUTFILE} 72 | IMAGE_NAME=${OUTPUTFILE} 73 | fi 74 | echo File saved as $IMAGE_NAME 75 | -------------------------------------------------------------------------------- /clean-ci-resources.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=${CONFIG:-cluster_config.sh} 4 | if [ -r "$CONFIG" ]; then 5 | source ./${CONFIG} 6 | fi 7 | 8 | case "$(openstack security group show -f value -c id default)" in 9 | ac891596-df7f-4533-9205-62c8f3976f46) 10 | >&2 echo 'Operating on MOC' 11 | ;; 12 | 1e7008c1-10f4-4d09-9d6e-d3de70b62eb6) 13 | >&2 echo 'Operating on VEXXHOST' 14 | ;; 15 | *) 16 | >&2 echo "Refusing to run on anything else than the CI tenant" 17 | exit 1 18 | esac 19 | 20 | declare \ 21 | concurrently=false \ 22 | json=false 23 | 24 | while getopts cj opt; do 25 | case "$opt" in 26 | c) concurrently=true ;; 27 | j) json=true ;; 28 | *) >&2 echo "Unknown flag: $opt"; exit 2 ;; 29 | esac 30 | done 31 | 32 | resultfile="$(mktemp)" 33 | trap 'rm $resultfile' EXIT 34 | 35 | if [ "$json" = true ]; then 36 | cat > $resultfile <<< '{}' 37 | fi 38 | 39 | report() { 40 | declare \ 41 | result='' \ 42 | resource_type="$*" 43 | 44 | while read -r resource_id; do 45 | if [ "$json" = true ]; then 46 | result=$(jq ".\"$resource_type\" += [\"$resource_id\"]" "$resultfile") 47 | else 48 | result="$(printf '%s\t%s' "$resource_type" "$resource_id" | cat "$resultfile" - )" 49 | fi 50 | cat > "$resultfile" <<< "$result" 51 | echo "$resource_id" 52 | done 53 | } 54 | 55 | for cluster_id in $(./list-clusters -ls); do 56 | if [ "$concurrently" = true ]; then 57 | time ./destroy_cluster.sh -i "$(echo "$cluster_id" | report cluster)" >&2 & 58 | else 59 | time ./destroy_cluster.sh -i "$(echo "$cluster_id" | report cluster)" >&2 60 | fi 61 | done 62 | 63 | # Clean leftover containers 64 | openstack container list -f value -c Name \ 65 | | grep -vf <(./list-clusters -a) \ 66 | | report container \ 67 | | xargs --verbose --no-run-if-empty openstack container delete -r \ 68 | >&2 69 | 70 | for resource in 'volume snapshot' 'volume' 'floating ip'; do 71 | # shellcheck disable=SC2086 72 | ./stale -q $resource | report $resource | xargs --verbose --no-run-if-empty openstack $resource delete >&2 73 | done 74 | 75 | cat "$resultfile" 76 | -------------------------------------------------------------------------------- /list-clusters: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuo pipefail 4 | 5 | unrecognised_command() { 6 | echo "Unrecognised command: $*" 7 | exit 1 8 | } 9 | 10 | print_help() { 11 | echo 'https://github.com/shiftstack/shiftstack-ci' 12 | echo 13 | echo 'list-clusters [ -a | -s ] [ -l ]' 14 | echo 15 | echo 'Prints the IDs of the detected clusters, based on their Network.' 16 | echo 17 | echo -e '\t-a only lists active clusters' 18 | echo -e '\t-s only lists stale clusters' 19 | echo 20 | echo -e '\t-l prints the full cluster name. Otherwise, truncates at 14 characters' 21 | echo 22 | echo 'Clusters are identified as stale if their network is more than 5 hours old.' 23 | } 24 | 25 | print_cluster_id() { 26 | declare \ 27 | cluster_id="$1" \ 28 | format="$2" 29 | 30 | case "$format" in 31 | 'long' ) echo "$cluster_id" ;; 32 | 'short') echo "${cluster_id:0:14}" ;; 33 | * ) >&2 echo "wrong format '$format'" ; exit 1 ;; 34 | esac 35 | } 36 | 37 | VALID_LIMIT="$(date --date='-5 hours' +%s)" 38 | readonly VALID_LIMIT 39 | 40 | declare filter='' 41 | declare format='short' 42 | 43 | while getopts lash o; do 44 | case "$o" in 45 | l) format='long' ;; 46 | a) filter='active' ;; 47 | s) filter='stale' ;; 48 | h) print_help; exit ;; 49 | *) unrecognised_command "$@" ;; 50 | esac 51 | done 52 | 53 | for network in $(openstack network list -c Name -f value); do 54 | if [[ $network = *-*-openshift ]] || [[ $network = *-*-network ]]; then 55 | declare CLUSTER_ID="$network" 56 | 57 | # IPI 58 | CLUSTER_ID="${CLUSTER_ID%-openshift}" 59 | # UPI 60 | CLUSTER_ID="${CLUSTER_ID%-network}" 61 | 62 | case "$filter" in 63 | 'active') 64 | CREATION_TIME=$(openstack network show "$network" -c created_at -f value) 65 | CREATION_TIMESTAMP=$(date --date="$CREATION_TIME" +%s) 66 | if [[ "$CREATION_TIMESTAMP" -ge "$VALID_LIMIT" ]]; then 67 | print_cluster_id "$CLUSTER_ID" "$format" 68 | fi 69 | ;; 70 | 'stale') 71 | CREATION_TIME=$(openstack network show "$network" -c created_at -f value) 72 | CREATION_TIMESTAMP=$(date --date="$CREATION_TIME" +%s) 73 | if [[ "$CREATION_TIMESTAMP" -lt "$VALID_LIMIT" ]]; then 74 | print_cluster_id "$CLUSTER_ID" "$format" 75 | fi 76 | ;; 77 | *) 78 | print_cluster_id "$CLUSTER_ID" "$format" 79 | ;; 80 | esac 81 | fi 82 | done 83 | -------------------------------------------------------------------------------- /report.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuo pipefail 4 | 5 | # Requirements: 6 | # * python-openstackclient 7 | # * jq 8 | 9 | 10 | print_help() { 11 | echo -e 'Run the CI cleanup, store logs and output a report.' 12 | echo 13 | echo -e 'Use:' 14 | echo -e "\t${0} [-o log_container -c cloud] [-m metrics_file] target_cloud..." 15 | echo 16 | echo -e 'Options:' 17 | echo -e "\t-o: The name of a Swift container where to store logs." 18 | echo -e "\t-c: The cloud where the Swift container for logs is situated." 19 | echo -e "\t-m: A file where to store metrics." 20 | } 21 | 22 | declare \ 23 | log_cloud='' \ 24 | log_container='' \ 25 | metrics=/dev/null \ 26 | log_file=/dev/stderr 27 | 28 | while getopts c:o:m:h opt; do 29 | case "$opt" in 30 | c) log_cloud="$OPTARG" ;; 31 | o) log_container="$OPTARG" ;; 32 | m) metrics="$OPTARG" ;; 33 | h) print_help; exit 0 ;; 34 | *) print_help; exit 1 ;; 35 | esac 36 | done 37 | readonly log_cloud log_container metrics 38 | shift $((OPTIND-1)) 39 | 40 | if [[ -n "$log_container" ]]; then 41 | if [[ -z "$log_cloud" ]]; then 42 | >&2 echo 'Log container (-o) set, but log cloud (-c) not set. Exiting.' 43 | exit 1 44 | fi 45 | else 46 | >&2 echo "Log container (-o) not set. Redirecting logs to $log_file" 47 | fi 48 | 49 | increment() { 50 | declare -r \ 51 | metrics_file="$1" \ 52 | cloud="$2" \ 53 | property="${3// /_}" \ 54 | increment="${4:-1}" 55 | 56 | metric_name="${property}{cloud=\"${cloud}\"}" 57 | 58 | if ! grep -q "$metric_name" "$metrics_file"; then 59 | echo "${metric_name} ${increment}" >> "$metrics_file" 60 | else 61 | tmp_metrics=$(<"$metrics_file") 62 | search="\(${metric_name}\) \([0-9]\+\)" 63 | replace="printf '%s %s' '\1' \"\$((\2+${increment}))\"" 64 | sed "s|${search}|${replace}|e" <<< "$tmp_metrics" > "$metrics_file" 65 | fi 66 | } 67 | 68 | to_metrics() { 69 | declare -r \ 70 | metrics_file="$1" \ 71 | cloud="$2" 72 | 73 | touch "$metrics_file" 74 | 75 | while IFS=$'\t' read -ra resource; do 76 | increment "$metrics_file" "$cloud" "${resource[0]}" 77 | done 78 | } 79 | 80 | for OS_CLOUD in "$@"; do 81 | if [[ -n "$log_container" ]]; then 82 | log_filename="clean-ci-log_$(date +'%s')_${OS_CLOUD}.txt" 83 | log_file="$(mktemp)" 84 | fi 85 | 86 | export OS_CLOUD 87 | ./clean-ci-resources.sh 2> "$log_file" | to_metrics "$metrics" "$OS_CLOUD" 88 | 89 | if [[ -n "$log_container" ]]; then 90 | openstack --os-cloud="$log_cloud" object create -f value -c object --name "$log_filename" "$log_container" "$log_file" 91 | rm "$log_file" 92 | fi 93 | done 94 | -------------------------------------------------------------------------------- /bot/clean-ci-resources.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - hosts: all 4 | 5 | vars_files: 6 | - cloud-credentials.json 7 | 8 | tasks: 9 | - name: 'Install system packages' 10 | become: yes 11 | dnf: 12 | name: 13 | - git 14 | - jq 15 | - python-openstackclient 16 | - caddy 17 | state: latest 18 | 19 | - name: 'Add the clean-ci-resources user' 20 | become: yes 21 | user: 22 | name: clean-ci-resources 23 | 24 | - name: 'Add the clean-ci-resources metrics directory' 25 | become: yes 26 | file: 27 | name: /var/clean-ci-resources 28 | state: directory 29 | owner: clean-ci-resources 30 | group: caddy 31 | mode: g+r 32 | 33 | - name: 'Add an openstack config directory' 34 | become: yes 35 | become_user: clean-ci-resources 36 | file: 37 | name: /home/clean-ci-resources/.config/openstack 38 | state: directory 39 | 40 | - name: 'Add clouds.yaml' 41 | become: yes 42 | become_user: clean-ci-resources 43 | template: 44 | src: templates/clouds.yaml.j2 45 | dest: /home/clean-ci-resources/.config/openstack/clouds.yaml 46 | 47 | - name: 'Add secure.yaml' 48 | become: yes 49 | become_user: clean-ci-resources 50 | template: 51 | src: templates/secure.yaml.j2 52 | dest: /home/clean-ci-resources/.config/openstack/secure.yaml 53 | 54 | - name: 'Install openshift-install' 55 | become: yes 56 | unarchive: 57 | remote_src: yes 58 | src: '{{ openshift_install_src }}' 59 | dest: /usr/bin/ 60 | exclude: 61 | - README.md 62 | 63 | - name: 'Clone shiftstack-ci' 64 | become: yes 65 | become_user: clean-ci-resources 66 | git: 67 | repo: 'https://github.com/shiftstack/shiftstack-ci.git' 68 | dest: /home/clean-ci-resources/shiftstack-ci 69 | 70 | - name: 'Add metrics webserver config' 71 | become: yes 72 | template: 73 | src: templates/Caddyfile.j2 74 | dest: /etc/caddy/Caddyfile 75 | 76 | - name: 'Create the systemd service for clean-ci-resources ' 77 | become: yes 78 | template: 79 | src: templates/clean-ci-resources.service.j2 80 | dest: /lib/systemd/system/clean-ci-resources.service 81 | 82 | - name: 'Create the systemd timer for clean-ci-resources ' 83 | become: yes 84 | template: 85 | src: templates/clean-ci-resources.timer.j2 86 | dest: /lib/systemd/system/clean-ci-resources.timer 87 | 88 | - name: 'Enable the clean-ci-resources timer' 89 | become: yes 90 | systemd: 91 | name: clean-ci-resources.timer 92 | enabled: yes 93 | state: started 94 | 95 | - name: 'Enable the metrics webserver' 96 | become: yes 97 | systemd: 98 | name: caddy.service 99 | enabled: yes 100 | state: started 101 | -------------------------------------------------------------------------------- /cluster_config.sh.example: -------------------------------------------------------------------------------- 1 | eval "$(go env)" 2 | 3 | export OPENSHIFT_INSTALL_DATA="$GOPATH/src/github.com/openshift/installer/data/data" 4 | export BASE_DOMAIN=shiftstack.test 5 | 6 | # Get your own pull secret from try.openshift.com 7 | export PULL_SECRET='{"auths": { "quay.io": { "auth": "xxx", "email": "" }}}' 8 | export SSH_PUB_KEY="`cat $HOME/.ssh/id_rsa.pub`" 9 | 10 | export MASTER_COUNT=3 11 | export WORKER_COUNT=3 12 | 13 | ############################################## 14 | # The following settings are platform specific 15 | ############################################## 16 | 17 | # Give a different cluster name for each of the platforms you're deploying on 18 | # since otherwise you'll get conflicts in your /etc/hosts file 19 | # export CLUSTER_NAME="" 20 | 21 | # export OPENSTACK_FLAVOR=m1.xlarge 22 | # If not defined, workers use the same flavor as controllers 23 | # export OPENSTACK_WORKER_FLAVOR=m1.large 24 | 25 | # Use the following variables to use boot from volume 26 | # export OPENSTACK_MASTER_VOLUME_TYPE=performance 27 | # export OPENSTACK_MASTER_VOLUME_SIZE=25 28 | # export OPENSTACK_WORKER_VOLUME_TYPE=performance 29 | # export OPENSTACK_WORKER_VOLUME_SIZE=25 30 | 31 | # export OPENSTACK_EXTERNAL_NETWORK=external 32 | 33 | # The installer automatically uploads the RHCOS image to glance. 34 | # While this allows to ensure the right image is used, this also means you'll 35 | # need to transfer 2GB both ways when deploying a cluster which may not be the 36 | # most convenient for development. You can set the following variable to point 37 | # to an existing image to skip this step: 38 | # export OPENSHIFT_INSTALL_OS_IMAGE_OVERRIDE="rhcos-4.6" 39 | 40 | 41 | # For example, if you wanted to configure more than one cloud, you could use 42 | # something like the following: 43 | 44 | # case $OS_CLOUD in 45 | # 46 | # "moc") 47 | # export CLUSTER_NAME="cluster-moc" 48 | # export OPENSTACK_FLAVOR=m1.s2.xlarge 49 | # export OPENSTACK_WORKER_FLAVOR=m1.s2.large 50 | # export OPENSTACK_MASTER_VOLUME_TYPE=performance 51 | # export OPENSTACK_MASTER_VOLUME_SIZE=25 52 | # export OPENSTACK_WORKER_VOLUME_TYPE=performance 53 | # export OPENSTACK_WORKER_VOLUME_SIZE=25 54 | # export OPENSTACK_EXTERNAL_NETWORK=external 55 | # ;; 56 | # 57 | # "psi") 58 | # export CLUSTER_NAME="cluster-psi" 59 | # export OPENSTACK_FLAVOR=ci.m1.xlarge 60 | # export OPENSTACK_WORKER_FLAVOR=ci.m1.large 61 | # # export OPENSTACK_EXTERNAL_NETWORK=provider_net_shared 62 | # export OPENSTACK_EXTERNAL_NETWORK=provider_net_shared_3 63 | # ;; 64 | # 65 | # "psi-public") 66 | # export CLUSTER_NAME="cluster-psi-pub" 67 | # export OPENSTACK_FLAVOR=ci.s.xl 68 | # export OPENSTACK_WORKER_FLAVOR=s.l 69 | # export OPENSTACK_EXTERNAL_NETWORK=internet 70 | # ;; 71 | # 72 | # *) 73 | # echo -n "Unknown OS_CLOUD=$OS_CLOUD" 74 | # ;; 75 | # esac 76 | -------------------------------------------------------------------------------- /refresh_rhcos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu 3 | set -o pipefail 4 | 5 | if [ -z "$OS_CLOUD" ]; then 6 | echo 'Set your OS_CLOUD environment variable' 7 | exit 1 8 | fi 9 | 10 | BRANCH="4.2" 11 | 12 | opts=$(getopt -n "$0" -o "b:" --long 'branch:' -- "$@") 13 | 14 | eval set "--$opts" 15 | 16 | CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/openshift-installer/image_cache" 17 | mkdir -p "$CACHE_DIR" 18 | 19 | while [[ $# -gt 0 ]]; do 20 | case "$1" in 21 | -b|--branch) 22 | BRANCH=$2 23 | shift 2 24 | ;; 25 | 26 | *) 27 | break 28 | ;; 29 | esac 30 | done 31 | 32 | if [ "$BRANCH" == "4.2" ]; then 33 | REAL_BRANCH_NAME="release-$BRANCH" 34 | # We want to leave 4.2 image under the rhcos name 35 | IMAGE_NAME="rhcos" 36 | else 37 | REAL_BRANCH_NAME="release-$BRANCH" 38 | IMAGE_NAME="rhcos-$BRANCH" 39 | fi 40 | 41 | RHCOS_VERSIONS_FILE="$(mktemp)" 42 | curl --silent -o "$RHCOS_VERSIONS_FILE" "https://raw.githubusercontent.com/openshift/installer/${REAL_BRANCH_NAME}/data/data/rhcos.json" 43 | 44 | IMAGE_SHA="$(jq --raw-output '.images.openstack."uncompressed-sha256"' "$RHCOS_VERSIONS_FILE")" 45 | IMAGE_URL="$(jq --raw-output '.baseURI + .images.openstack.path' "$RHCOS_VERSIONS_FILE")" 46 | IMAGE_VERSION="$(jq --raw-output '."ostree-version"' "$RHCOS_VERSIONS_FILE")" 47 | 48 | current_image_version="$(mktemp)" 49 | openstack image show -c properties -f json "$IMAGE_NAME" > "$current_image_version" || true 50 | 51 | if grep -q "$IMAGE_VERSION" "$current_image_version"; then 52 | echo "RHCOS image '${IMAGE_NAME}' already at the latest version '$IMAGE_VERSION'" 53 | exit 54 | fi 55 | 56 | LOCAL_IMAGE_FILE="${CACHE_DIR}/$(echo -n "${IMAGE_URL}?sha256=${IMAGE_SHA}" | md5sum | cut -d ' ' -f1)" 57 | 58 | if [ -f "$LOCAL_IMAGE_FILE" ]; then 59 | echo "Found cached image $LOCAL_IMAGE_FILE" 60 | else 61 | echo "Downloading RHCOS image from:" 62 | echo "$IMAGE_URL" 63 | 64 | if [[ "$IMAGE_URL" == *.gz ]]; then 65 | curl --insecure --compressed -L -o "${LOCAL_IMAGE_FILE}.gz" "$IMAGE_URL" 66 | gunzip -f "${LOCAL_IMAGE_FILE}.gz" 67 | else 68 | curl --insecure --compressed -L -o "$LOCAL_IMAGE_FILE" "$IMAGE_URL" 69 | fi 70 | fi 71 | 72 | echo "Verifying image..." 73 | if ! sha256sum --quiet -c <(echo -n "${IMAGE_SHA} ${LOCAL_IMAGE_FILE}"); then 74 | echo 'Image is corrupted. Exiting...' 75 | exit 1 76 | fi 77 | 78 | echo "Uploading image to '${OS_CLOUD}' as '${IMAGE_NAME}-new'" 79 | new_image_id="$(openstack image create "${IMAGE_NAME}-new" --container-format bare --disk-format qcow2 --file "$LOCAL_IMAGE_FILE" --private --property version="$IMAGE_VERSION" --format value --column id)" 80 | 81 | echo "Replace old '$IMAGE_NAME' image with new one on '${OS_CLOUD}'" 82 | 83 | # Always only keep one backup of rhcos image 84 | openstack image delete "${IMAGE_NAME}-old" || true 85 | 86 | # Then swap the images 87 | openstack image set --name "${IMAGE_NAME}-old" "$IMAGE_NAME" || true 88 | openstack image set --name "$IMAGE_NAME" "$new_image_id" 89 | 90 | echo Done 91 | -------------------------------------------------------------------------------- /stale: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeuo pipefail 4 | 5 | unknown_command() { 6 | echo "Unknown command: $*" 7 | exit 1 8 | } 9 | 10 | print_help() { 11 | echo 'https://github.com/shiftstack/shiftstack-ci/stale' 12 | echo 13 | echo 'Prints the IDs of the stale resources, with the timestamp of the last update and the resource name.' 14 | echo 15 | echo 'Usage:' 16 | echo "$0 [-un|-q] " 17 | echo 18 | echo '"resource_type" can be any openstack resource type.' 19 | echo 'Resources are identified as stale if they were last updated more than 5 hours ago.' 20 | echo 21 | echo -u Only print the ID and the timestamp of the last update 22 | echo -n Only print the ID and the resource name 23 | echo -q Only print the ID 24 | echo 25 | echo 'Examples:' 26 | echo "$0 port" 27 | echo "$0 -q floating ip" 28 | } 29 | 30 | declare \ 31 | print_name=no \ 32 | print_updated=no \ 33 | quiet=no 34 | while getopts nuqh o; do 35 | case "$o" in 36 | n) print_name=yes ;; 37 | u) print_updated=yes ;; 38 | q) quiet=yes ;; 39 | h) print_help; exit ;; 40 | *) unknown_command "$@" ;; 41 | esac 42 | done 43 | if [[ $print_name == 'yes' ]] || [[ $print_updated == 'yes' ]]; then 44 | if [[ $quiet == 'yes' ]]; then 45 | >&2 echo '-q can not be used with -n or -u.' 46 | exit 2 47 | fi 48 | else 49 | if [[ $quiet != 'yes' ]]; then 50 | print_name=yes 51 | print_updated=yes 52 | fi 53 | fi 54 | shift $((OPTIND - 1)) 55 | 56 | declare -r resource_type="$*" 57 | 58 | declare valid_limit 59 | valid_limit="$(date --date='-5 hours' +%s)" 60 | readonly valid_limit 61 | 62 | list_server() { 63 | for resource_id in $(openstack server list -f value -c ID); do 64 | res="$(openstack server show -f json -c updated -c name "$resource_id")" 65 | update_time="$(jq -r '.updated' <<< "$res")" 66 | name="$(jq -r '.name' <<< "$res")" 67 | printf '%s %s %s\n' "$resource_id" "$update_time" "$name" 68 | done 69 | } 70 | 71 | list_port() { 72 | openstack port list -f json -c ID -c Name -c 'Updated At' \ 73 | | jq -r '.[] | "\(.ID) \(."Updated At") \(.Name)"' 74 | } 75 | 76 | list_generic() { 77 | declare rt="$1" 78 | for resource_id in $(openstack "$rt" list -f value -c ID); do 79 | res="$(openstack "$rt" show -f json -c updated_at -c name "$resource_id")" 80 | update_time="$(jq -r '.updated_at' <<< "$res")" 81 | name="$(jq -r '.name' <<< "$res")" 82 | printf '%s %s %s\n' "$resource_id" "$update_time" "$name" 83 | done 84 | } 85 | 86 | case $resource_type in 87 | server) 88 | list_server ;; 89 | port) 90 | list_port ;; 91 | 'network'|'network trunk'|'subnet'|'floating ip'|'security group'|'volume'|'volume snapshot') 92 | list_generic "$resource_type" ;; 93 | 'server group') 94 | >&2 printf 'Creation date is not available for %s.' "$resource_type" 95 | exit 3 96 | ;; 97 | *) 98 | >&2 printf 'Resource "%s" not implemented.' "$resource_type" 99 | exit 3 100 | ;; 101 | esac | while read -r resource_id update_time name; do 102 | if [[ "$(date --date="$update_time" +%s)" -lt "$valid_limit" ]]; then 103 | printf '%s' "$resource_id" 104 | if [[ $print_updated == 'yes' ]]; then 105 | printf ' %s' "$update_time" 106 | fi 107 | if [[ $print_name == 'yes' ]]; then 108 | printf ' %s' "$name" 109 | fi 110 | printf '\n' 111 | fi 112 | done 113 | -------------------------------------------------------------------------------- /docs/README.adoc: -------------------------------------------------------------------------------- 1 | = ShiftStack CI 2 | 3 | Each OpenShift on OpenStack continuous integration test job runs on one of two clouds: 4 | 5 | * *MOC*: massopen.cloud running OSP 13 6 | * *Vexxhost*: A private cloud offering likely running OpenStack Ussuri 7 | 8 | Currently, we have three different test suites: 9 | 10 | * *Parallel*: The Conformance test suite, executed parallelizing tests 11 | * *Serial*: The Conformance test suite, executed one job at a time 12 | * *Early*: Smoke tests 13 | 14 | Currently, our jobs deploy on clouds with equivalent characteristics: 15 | 16 | * Control Plane (and bootstrap) nodes boot from a 25GB high-performance Cinder volume 17 | * Control Plane: 3 VMs with: 18 | ** 8 vCPUs 19 | ** 16 GB RAM 20 | ** 25 GB disk 21 | * Compute Nodes: 3 VMs with: 22 | ** 8 vCPUs 23 | ** 16 GB RAM 24 | ** 25 GB disk 25 | * OpenShift SDN 26 | * Installer-provisioned network 27 | * FIP-powered connectivity (we use AWS Route53 as the external DNS) 28 | * The OpenStack cloud is using a valid HTTPS certificate (no cacert in clouds.yaml) 29 | * Swift as a backend for cluster-image-registry-operator 30 | 31 | .ShiftStack periodics 32 | |=== 33 | |Installer |Branch |Test suite |Job name |Cloud (see top) 34 | 35 | |IPI 36 | |4.6 37 | |Parallel 38 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.6-informing#release-openshift-ocp-installer-e2e-openstack-4.6[release-openshift-ocp-installer-e2e-openstack-4.6] 39 | |Vexxhost 40 | 41 | |IPI 42 | |4.6 43 | |Serial 44 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.6-informing#release-openshift-ocp-installer-e2e-openstack-serial-4.6[release-openshift-ocp-installer-e2e-openstack-serial-4.6] 45 | |Vexxhost 46 | 47 | |IPI 48 | |4.5 49 | |Parallel 50 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.5-informing#release-openshift-ocp-installer-e2e-openstack-4.5[release-openshift-ocp-installer-e2e-openstack-4.5] 51 | |Vexxhost 52 | 53 | |IPI 54 | |4.5 55 | |Serial 56 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.5-informing#release-openshift-ocp-installer-e2e-openstack-serial-4.5[release-openshift-ocp-installer-e2e-openstack-serial-4.5] 57 | |Vexxhost 58 | 59 | |IPI 60 | |4.4 61 | |Parallel 62 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.4-informing#release-openshift-ocp-installer-e2e-openstack-4.4[release-openshift-ocp-installer-e2e-openstack-4.4] 63 | |MOC 64 | 65 | |IPI 66 | |4.4 67 | |Serial 68 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.4-informing#release-openshift-ocp-installer-e2e-openstack-serial-4.4[release-openshift-ocp-installer-e2e-openstack-serial-4.4] 69 | |MOC 70 | 71 | |IPI 72 | |4.3 73 | |Parallel 74 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.3-informing#release-openshift-ocp-installer-e2e-openstack-4.3[release-openshift-ocp-installer-e2e-openstack-4.3] 75 | |MOC 76 | 77 | |IPI 78 | |4.3 79 | |Serial 80 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.3-informing#release-openshift-ocp-installer-e2e-openstack-serial-4.3[release-openshift-ocp-installer-e2e-openstack-serial-4.3] 81 | |MOC 82 | 83 | |IPI 84 | |4.2 85 | |Parallel 86 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.2-informing#release-openshift-ocp-installer-e2e-openstack-4.2[release-openshift-ocp-installer-e2e-openstack-4.2] 87 | |MOC 88 | 89 | |IPI 90 | |4.2 91 | |Serial 92 | |https://testgrid.k8s.io/redhat-openshift-ocp-release-4.2-informing#release-openshift-ocp-installer-e2e-openstack-serial-4.2[release-openshift-ocp-installer-e2e-openstack-serial-4.2] 93 | |MOC 94 | |=== 95 | 96 | .ShiftStack presubmits 97 | |=== 98 | |Installer |Branch |Test suite |Job name |Cloud (see top) 99 | 100 | |IPI 101 | |All 102 | |Early 103 | |e2e-openstack 104 | |MOC 105 | 106 | |UPI 107 | |4.6, 4.5, 4.4 108 | |Early 109 | |e2e-openstack-upi 110 | |MOC 111 | |=== 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # shiftstack-ci 2 | 3 | This repository contains tools to help build and simplify a testing environment 4 | for the development of OpenShift 4.x installation against an OpenStack cloud. 5 | 6 | It is complementary to 7 | [ocp-doit](https://github.com/shiftstack-dev-tools/ocp-doit) that focus on 8 | deploying OCP using a standalone TripleO. 9 | 10 | ## Prerequisites 11 | 12 | Access to an OpenStack cloud fitting the [OpenShift on OpenStack 13 | requirements](https://github.com/openshift/installer/tree/master/docs/user/openstack). 14 | 15 | The RHCOS image can be downloaded from the [release 16 | browser](https://releases-redhat-coreos-dev.cloud.paas.upshift.redhat.com). 17 | 18 | It may be possible that the flavors available from your OpenStack cloud 19 | provider set a disk size smaller than what is required for the rhcos image. If 20 | that's the case, you can shrink the image with `qemu-img`, for instance: 21 | 22 | ``` 23 | qemu-img resize rhcos-maipo-400.7.20190312.0-openstack.qcow2 --shrink 10G 24 | ``` 25 | 26 | Additionally the cloud must have enough capacity for: 27 | - 7 m1.medium nodes 28 | - 1 floating IP 29 | 30 | Finally, you'll need a go dev environment for building the installer. [This 31 | guide](https://medium.com/@fsufitch/go-environment-setup-minus-the-insanity-b872f34351c8) 32 | has gifs of cats, and is highly recommended if you are struggling with this. 33 | 34 | ## Set up 35 | 36 | Before running any of the scripts in this repository, there is minimal setup 37 | required. 38 | 39 | You will need to clone the [openshift 40 | installer](http://github.com/openshift/installer). Rather than clone using 41 | `git`, it is much more convenient to use `go get`, since it will put it where 42 | it belongs for you. 43 | 44 | ```bash 45 | go get github.com/openshift/installer 46 | ``` 47 | 48 | Make sure to export the `OS_CLOUD` environment variable to the name of your 49 | OpenStack cloud provider from your `$HOME/.config/openstack/clouds.yaml` file. 50 | 51 | Lastly, you need some binaries to work with OpenShift and OpenStack. This is 52 | easy, just run: 53 | 54 | ```bash 55 | sudo dnf install jq python2-openstackclient origin-clients 56 | ``` 57 | 58 | ## Cluster Configuration 59 | 60 | Make a copy of the `cluster_config.sh.example` file: 61 | 62 | ```shell 63 | cp cluster_config.sh.example cluster_config.sh 64 | ``` 65 | 66 | Adjust the settings to match your environment. This will set up how and 67 | where your cluster gets built, so it is important to fill it out carefully. 68 | Here is a rundown of the important fields you will likely have to modify: 69 | 70 | ``` 71 | OS_CLOUD The cloud in your openstack cluster that resources will be consumed from. 72 | CLUSTER_NAME What your ocp cluster will be nicknamed. This naming scheme is propogated to all resources in the cluster. 73 | ``` 74 | 75 | Finally you need to obtain a pull secret from [here](https://cloud.redhat.com/openshift/install/osp/installer-provisioned), 76 | and replace `PULL_SECRET` vaiable with the new value. If you don't do this 77 | you can still install the cluster, but you won't be able to create new 78 | applications in OpenShift because you won't have access to private images. 79 | 80 | Once this has been set up, you can proceed with building the installer. 81 | 82 | ## Building the Installer 83 | 84 | Just run the convenience script: `build_ocp.sh`! You will have to do this 85 | before your first run, and every time you make a change to the installer. 86 | 87 | ## Deploying OpenShift 88 | 89 | This part is also pretty self-explanatory, the `run_ocp.sh` script will create 90 | a cluster, and the `destroy_cluster.sh` script will destroy it. Moving 91 | forwards, however, we will be looking to move away from building the cluster 92 | this way, and towards using the [CI 93 | operator](https://github.com/openshift/ci-operator/) as our primary means of 94 | testing. 95 | -------------------------------------------------------------------------------- /destroy_cluster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Ideally, we never have any bugs in cluster delete. 3 | # However, even in this ideal scenario, we need 4 | # protection from a patch under review breaking cluster delete 5 | # and filling up our tenant with undeletable resources. 6 | # In this case call the destroy script with `-f|--force` 7 | 8 | CONFIG=${CONFIG:-cluster_config.sh} 9 | if [ -r "$CONFIG" ]; then 10 | source ./${CONFIG} 11 | fi 12 | 13 | ARTIFACT_DIR=clusters/${CLUSTER_NAME} 14 | 15 | opts=$(getopt -n "$0" -o "fi:" --long "force,infra-id:" -- "$@") 16 | 17 | eval set --$opts 18 | 19 | while [[ $# -gt 0 ]]; do 20 | case "$1" in 21 | -f|--force) 22 | FORCE=true 23 | shift 24 | ;; 25 | 26 | -i|--infra-id) 27 | INFRA_ID=$2 28 | shift 2 29 | ;; 30 | 31 | *) 32 | break 33 | ;; 34 | esac 35 | done 36 | 37 | declare -r installer="${OPENSHIFT_INSTALLER:-openshift-install}" 38 | 39 | # Remove entries from /etc/hosts and ssh config 40 | if sudo -l sed /etc/hosts >/dev/null; then 41 | sudo sed -i "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/d" /etc/hosts 42 | fi 43 | if [[ -w "${HOME}/.ssh/config" ]]; then 44 | sed -i "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/d" $HOME/.ssh/config 45 | fi 46 | 47 | if [ ! -z "$INFRA_ID" ]; then 48 | TMP_DIR=$(mktemp -d -t shiftstack-XXXXXXXXXX) 49 | echo "{\"clusterName\":\"$CLUSTER_NAME\",\"infraID\":\"$INFRA_ID\",\"openstack\":{\"cloud\":\"$OS_CLOUD\",\"identifier\":{\"openshiftClusterID\":\"$INFRA_ID\"}}}" > $TMP_DIR/metadata.json 50 | fi 51 | 52 | if [[ $FORCE == true ]]; then 53 | echo Destroying cluster using openstack cli 54 | if [ -z "$INFRA_ID" ] && [ -f $ARTIFACT_DIR/metadata.json ]; then 55 | # elements created by the cluster are named $CLUSTER_NAME-hash by the installer 56 | INFRA_ID=$(jq .infraID $ARTIFACT_DIR/metadata.json | sed "s/\"//g") 57 | fi 58 | 59 | if [ -z "$INFRA_ID" ]; then 60 | echo "Could not find infrastructure id." 61 | echo "You may specify it with -i|--infra-id option to the script." 62 | exit 1 63 | fi 64 | 65 | openstack server list -c ID -f value --name $INFRA_ID | xargs --no-run-if-empty openstack server delete 66 | openstack router remove subnet $INFRA_ID-external-router $INFRA_ID-service 67 | openstack router remove subnet $INFRA_ID-external-router $INFRA_ID-nodes 68 | # delete interfaces from the router 69 | openstack network trunk list -c Name -f value | grep $INFRA_ID | xargs --no-run-if-empty openstack network trunk delete 70 | openstack port list --network $INFRA_ID-openshift -c ID -f value | xargs --no-run-if-empty openstack port delete 71 | 72 | # delete interfaces from the router 73 | PORT=$(openstack router show $INFRA_ID-external-router -c interfaces_info -f value | cut -d '"' -f 12) 74 | if [ -n "$PORT" ]; then 75 | openstack router remove port $INFRA_ID-external-router $PORT 76 | fi 77 | 78 | openstack router unset --external-gateway $INFRA_ID-external-router 79 | openstack router delete $INFRA_ID-external-router 80 | 81 | # IPI network 82 | openstack network delete $INFRA_ID-openshift 83 | 84 | # UPI network 85 | openstack network delete $INFRA_ID-network 86 | 87 | openstack security group delete $INFRA_ID-api 88 | openstack security group delete $INFRA_ID-master 89 | openstack security group delete $INFRA_ID-worker 90 | 91 | openstack server group delete $INFRA_ID-master 92 | 93 | for c in $(openstack container list -f value); do 94 | echo $c 95 | openstack container show $c | grep $INFRA_ID 96 | if [ $? -eq 0 ]; then 97 | CONTAINER=$c 98 | fi 99 | done 100 | 101 | if [ ! -z "$CONTAINER" ]; then 102 | openstack object list -f value $CONTAINER | xargs --no-run-if-empty openstack object delete $CONTAINER 103 | openstack container delete $CONTAINER 104 | fi 105 | else 106 | echo Destroying cluster using openshift-install 107 | "$installer" --log-level=debug destroy cluster --dir ${TMP_DIR:-$ARTIFACT_DIR} 108 | fi 109 | 110 | if [ ! -z "$TMP_DIR" ]; then 111 | rm -rf $TMP_DIR 112 | fi 113 | -------------------------------------------------------------------------------- /populate_mirror.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- coding: utf-8 -*- 3 | # Copyright 2020 Red Hat, Inc. 4 | # All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 7 | # not use this file except in compliance with the License. You may obtain 8 | # a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15 | # License for the specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | # This script is a helper to populate a mirror registry 19 | # for the installation of OpenShift in a restricted network 20 | # (e.g. without internet access). 21 | # It does what is documented here: https://tinyurl.com/y62uozsc 22 | # Note: It assumes that the local container registry is connected to the 23 | # mirror host, therefore to the Internet. 24 | # 25 | # Requirements: 26 | # - a functional container image registry (e.g. docker-registry) 27 | # - Internet access 28 | # - 8 GB available for the registry (subject to change) 29 | # - oc binary installed 30 | # - auth file generated with valid credentials 31 | 32 | set -e 33 | 34 | if ! command -v oc &> /dev/null; then 35 | echo "oc binary not found, exiting ..." 36 | exit 1 37 | fi 38 | 39 | : ${OC_REGISTRY_AUTH_FILE:="auth.json"} 40 | : ${TAG:="4.7.6-x86_64"} 41 | : ${PRODUCT_REPO:="quay.io/openshift-release-dev"} 42 | : ${RELEASE_NAME:="ocp-release"} 43 | : ${INSECURE:="false"} 44 | 45 | help() { 46 | echo "Populate a mirror registry for the installation of OpenShift in a restricted network" 47 | echo "" 48 | echo "Usage: ./populate_mirror.sh [options] -r myregistry.io" 49 | echo "Options:" 50 | echo "--auth path of registry auth file, default: ${OC_REGISTRY_AUTH_FILE}" 51 | echo "-d, --debug enable debug, default: false" 52 | echo "-h, --help show this message" 53 | echo "-i, --insecure do not verify TLS for mirror registry, default: ${INSECURE}" 54 | echo "-n, --name release name, default (for production): ${RELEASE_NAME}" 55 | echo "-p, --product product repository, including registry URL, default (for production): ${PRODUCT_REPO}" 56 | echo "-r, --registry mirror registry URL, including namespace (required), e.g.: myregistry.io/foobar" 57 | echo "-t, --tag openshift release tag, default: ${TAG}" 58 | echo "" 59 | } 60 | 61 | while [ $# -gt 0 ]; do 62 | case "$1" in 63 | -h|--help) 64 | help 65 | exit 0 66 | ;; 67 | -d|--debug) 68 | set -o xtrace 69 | shift 1 70 | ;; 71 | -r|--registry) 72 | LOCAL_REGISTRY=$2 73 | shift 2 74 | ;; 75 | -t|--tag) 76 | TAG=$2 77 | shift 2 78 | ;; 79 | --auth) 80 | OC_REGISTRY_AUTH_FILE=$2 81 | shift 2 82 | ;; 83 | -p|--product) 84 | PRODUCT_REPO=$2 85 | shift 2 86 | ;; 87 | -n|--name) 88 | RELEASE_NAME=$2 89 | shift 2 90 | ;; 91 | -i|--insecure) 92 | INSECURE="true" 93 | shift 1 94 | ;; 95 | *) 96 | echo "$0: error - unexpected argument $1" >&2; help; 97 | exit 1 98 | ;; 99 | esac 100 | done 101 | 102 | if [ -z "$LOCAL_REGISTRY" ]; then 103 | echo "No mirror registry URL provided, exiting ..." 104 | exit 1 105 | fi 106 | 107 | if [ ! -f "$OC_REGISTRY_AUTH_FILE" ]; then 108 | echo "$OC_REGISTRY_AUTH_FILE not found, exiting ..." 109 | exit 1 110 | fi 111 | 112 | echo "Directly push the release images to the local registry:" 113 | oc adm -a ${OC_REGISTRY_AUTH_FILE} release mirror --insecure=${INSECURE} \ 114 | --from=${PRODUCT_REPO}/${RELEASE_NAME}:${TAG} \ 115 | --to=${LOCAL_REGISTRY} \ 116 | --to-release-image=${LOCAL_REGISTRY}:${TAG} 117 | 118 | echo "Create the installation program that is based on the content:" 119 | echo "that we mirrored, extract it and pin it to the release" 120 | oc adm -a ${OC_REGISTRY_AUTH_FILE} release extract --insecure=${INSECURE} --command=openshift-install "${LOCAL_REGISTRY}:${TAG}" 121 | echo "You now have ./openshift-install ready to be used." 122 | -------------------------------------------------------------------------------- /ci-dns/create_ci_dns.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # TODO ci-dns VM must have the 128.31.27.48 FIP pointing to it 3 | # TODO(trown): remove hardcoding of net-id 4 | # TODO(mandre): need a ci-dns network 5 | # openstack network show ci-dns 6 | # +---------------------------+--------------------------------------+ 7 | # | Field | Value | 8 | # +---------------------------+--------------------------------------+ 9 | # | admin_state_up | UP | 10 | # | availability_zone_hints | | 11 | # | availability_zones | nova | 12 | # | created_at | 2019-03-25T15:46:44Z | 13 | # | description | | 14 | # | dns_domain | None | 15 | # | id | b978d863-7437-465d-86df-d1a5686f797f | 16 | # | ipv4_address_scope | None | 17 | # | ipv6_address_scope | None | 18 | # | is_default | None | 19 | # | is_vlan_transparent | None | 20 | # | mtu | 9000 | 21 | # | name | ci-dns | 22 | # | port_security_enabled | True | 23 | # | project_id | 593227d1d5d04cba8847d5b6b742e0a7 | 24 | # | provider:network_type | None | 25 | # | provider:physical_network | None | 26 | # | provider:segmentation_id | None | 27 | # | qos_policy_id | None | 28 | # | revision_number | 4 | 29 | # | router:external | Internal | 30 | # | segments | None | 31 | # | shared | False | 32 | # | status | ACTIVE | 33 | # | subnets | 9402ba42-e92b-4db0-88ec-d42ac8f55039 | 34 | # | tags | | 35 | # | updated_at | 2019-03-25T15:46:44Z | 36 | # +---------------------------+--------------------------------------+ 37 | # 38 | # openstack subnet show 9402ba42-e92b-4db0-88ec-d42ac8f55039 39 | # +-------------------+--------------------------------------+ 40 | # | Field | Value | 41 | # +-------------------+--------------------------------------+ 42 | # | allocation_pools | 192.168.23.2-192.168.23.254 | 43 | # | cidr | 192.168.23.0/24 | 44 | # | created_at | 2019-03-25T15:46:44Z | 45 | # | description | | 46 | # | dns_nameservers | | 47 | # | enable_dhcp | True | 48 | # | gateway_ip | 192.168.23.1 | 49 | # | host_routes | | 50 | # | id | 9402ba42-e92b-4db0-88ec-d42ac8f55039 | 51 | # | ip_version | 4 | 52 | # | ipv6_address_mode | None | 53 | # | ipv6_ra_mode | None | 54 | # | name | ci-dns | 55 | # | network_id | b978d863-7437-465d-86df-d1a5686f797f | 56 | # | project_id | 593227d1d5d04cba8847d5b6b742e0a7 | 57 | # | revision_number | 0 | 58 | # | segment_id | None | 59 | # | service_types | | 60 | # | subnetpool_id | None | 61 | # | tags | | 62 | # | updated_at | 2019-03-25T15:46:44Z | 63 | # +-------------------+--------------------------------------+ 64 | # 65 | # TODO(mandre): need a ci-dns security-group 66 | # direction='ingress', ethertype='IPv4', port_range_max='53', port_range_min='53', protocol='udp', remote_ip_prefix='; 0.0.0.0/0' 67 | # direction='ingress', ethertype='IPv4', port_range_max='53', port_range_min='53', protocol='tcp', remote_ip_prefix='; 0.0.0.0/0' 68 | # direction='ingress', ethertype='IPv4', protocol='icmp', remote_ip_prefix='0.0.0.0/0' 69 | # direction='egress', ethertype='IPv4' 70 | # direction='ingress', ethertype='IPv4', port_range_max='22', port_range_min='22', protocol='tcp', remote_ip_prefix='; 0.0.0.0/0' 71 | # direction='ingress', ethertype='IPv4', port_range_max='8080', port_range_min='8080', protocol='tcp', remote_ip_prefix='0.0.0.0/0' 72 | # direction='egress', ethertype='IPv6' 73 | 74 | # Transform yml to ign file using https://github.com/coreos/container-linux-config-transpiler 75 | 76 | NAME=ci-dns 77 | 78 | opts=$(getopt -n "$0" -o "n:" --long "name:" -- "$@") 79 | 80 | eval set --$opts 81 | 82 | while [[ $# -gt 0 ]]; do 83 | case "$1" in 84 | -n|--name) 85 | NAME=$2 86 | shift 2 87 | ;; 88 | 89 | *) 90 | break 91 | ;; 92 | esac 93 | done 94 | 95 | ci_dns_net_id=$(openstack network show ci-dns -f value -c id) 96 | 97 | openstack server create \ 98 | --user-data ./CI-DNS.ign \ 99 | --image rhcos \ 100 | --flavor m1.s2.medium \ 101 | --security-group default \ 102 | --security-group ci-dns \ 103 | --config-drive=true \ 104 | --nic net-id=${ci_dns_net_id} \ 105 | ${NAME} 106 | -------------------------------------------------------------------------------- /run_ocp.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | CONFIG=${CONFIG:-cluster_config.sh} 6 | if [ ! -r "$CONFIG" ]; then 7 | echo "Could not find cluster configuration file." 8 | echo "Make sure $CONFIG file exists in the shiftstack-ci directory and that it is readable" 9 | exit 1 10 | fi 11 | source ${CONFIG} 12 | 13 | set -x 14 | 15 | declare -r installer="${OPENSHIFT_INSTALLER:-$GOPATH/src/github.com/openshift/installer/bin/openshift-install}" 16 | 17 | # check whether we have a free floating IP 18 | FLOATING_IP=$(openstack floating ip list --status DOWN --network $OPENSTACK_EXTERNAL_NETWORK --long --format value -c "Floating IP Address" -c Description | grep ${CLUSTER_NAME} | sed 's/ .*//g') 19 | FLOATING_IP=$(echo $FLOATING_IP | cut -d ' ' -f1) 20 | 21 | # create new floating ip if doesn't exist 22 | if [ -z "$FLOATING_IP" ]; then 23 | FLOATING_IP=$(openstack floating ip create $OPENSTACK_EXTERNAL_NETWORK --description "${CLUSTER_NAME}-api" --format value --column floating_ip_address) 24 | fi 25 | 26 | hosts="# Generated by shiftstack for $CLUSTER_NAME - Do not edit 27 | $FLOATING_IP api.${CLUSTER_NAME}.${BASE_DOMAIN} 28 | # End of $CLUSTER_NAME nodes" 29 | 30 | old_hosts=$(awk "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/" /etc/hosts) 31 | 32 | if [ "${hosts}" != "${old_hosts}" ]; then 33 | echo Updating hosts file 34 | sudo sed -i "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/d" /etc/hosts 35 | echo "$hosts" | sudo tee -a /etc/hosts 36 | fi 37 | 38 | ssh_config="# Generated by shiftstack for $CLUSTER_NAME - Do not edit 39 | Host openshift-api-$CLUSTER_NAME 40 | Hostname $FLOATING_IP 41 | User core 42 | Port 22 43 | StrictHostKeyChecking no 44 | UserKnownHostsFile=/dev/null 45 | # End of $CLUSTER_NAME nodes" 46 | 47 | if [ ! -f "$HOME/.ssh/config" ]; then 48 | touch "$HOME/.ssh/config" 49 | chmod 600 "$HOME/.ssh/config" 50 | fi 51 | old_ssh_config=$(awk "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/" $HOME/.ssh/config) 52 | if [ "${ssh_config}" != "${old_ssh_config}" ]; then 53 | echo Updating ssh config file 54 | sed -i "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/d" $HOME/.ssh/config 55 | echo "$ssh_config" >> $HOME/.ssh/config 56 | fi 57 | 58 | ARTIFACT_DIR=clusters/${CLUSTER_NAME} 59 | 60 | rm -rf ${ARTIFACT_DIR} 61 | mkdir -p ${ARTIFACT_DIR} 62 | 63 | : "${OPENSTACK_WORKER_FLAVOR:=${OPENSTACK_FLAVOR}}" 64 | 65 | MASTER_ROOT_VOLUME="" 66 | if [[ ${OPENSTACK_MASTER_VOLUME_TYPE} != "" ]]; then 67 | MASTER_ROOT_VOLUME="rootVolume: 68 | size: ${OPENSTACK_MASTER_VOLUME_SIZE:-25} 69 | type: ${OPENSTACK_MASTER_VOLUME_TYPE}" 70 | fi 71 | WORKER_ROOT_VOLUME="" 72 | if [[ ${OPENSTACK_WORKER_VOLUME_TYPE} != "" ]]; then 73 | WORKER_ROOT_VOLUME="rootVolume: 74 | size: ${OPENSTACK_WORKER_VOLUME_SIZE:-25} 75 | type: ${OPENSTACK_WORKER_VOLUME_TYPE}" 76 | fi 77 | 78 | if [ ! -f ${ARTIFACT_DIR}/install-config.yaml ]; then 79 | export CLUSTER_ID=$(uuidgen --random) 80 | cat > ${ARTIFACT_DIR}/install-config.yaml << EOF 81 | apiVersion: v1 82 | baseDomain: ${BASE_DOMAIN} 83 | clusterID: ${CLUSTER_ID} 84 | compute: 85 | - name: worker 86 | platform: 87 | openstack: 88 | type: ${OPENSTACK_WORKER_FLAVOR} 89 | ${WORKER_ROOT_VOLUME} 90 | replicas: ${WORKER_COUNT} 91 | controlPlane: 92 | name: master 93 | platform: 94 | openstack: 95 | type: ${OPENSTACK_FLAVOR} 96 | ${MASTER_ROOT_VOLUME} 97 | replicas: ${MASTER_COUNT} 98 | metadata: 99 | name: ${CLUSTER_NAME} 100 | networking: 101 | clusterNetwork: 102 | - cidr: 10.128.0.0/14 103 | hostPrefix: 23 104 | machineNetwork: 105 | - cidr: 10.0.128.0/17 106 | networkType: OpenShiftSDN 107 | serviceNetwork: 108 | - 172.30.0.0/16 109 | platform: 110 | openstack: 111 | cloud: ${OS_CLOUD} 112 | externalNetwork: ${OPENSTACK_EXTERNAL_NETWORK} 113 | computeFlavor: ${OPENSTACK_FLAVOR} 114 | lbFloatingIP: ${FLOATING_IP} 115 | pullSecret: | 116 | ${PULL_SECRET} 117 | sshKey: | 118 | ${SSH_PUB_KEY} 119 | EOF 120 | fi 121 | 122 | "$installer" --log-level=debug ${1:-create} ${2:-cluster} --dir ${ARTIFACT_DIR} 123 | 124 | # Attaching FIP to ingress port to access the cluster from outside 125 | # check whether we have a free floating IP 126 | INGRESS_PORT=$(openstack port list --format value -c Name | awk "/${CLUSTER_NAME}.*-ingress-port/ {print}") 127 | if [ -n "$INGRESS_PORT" ]; then 128 | APPS_FLOATING_IP=$(openstack floating ip list --status DOWN --network $OPENSTACK_EXTERNAL_NETWORK --long --format value -c "Floating IP Address" -c Description | grep ${CLUSTER_NAME} | awk 'NF<=1 && NR==1 {print}') 129 | 130 | # create new floating ip if doesn't exist 131 | if [ -z "$APPS_FLOATING_IP" ]; then 132 | APPS_FLOATING_IP=$(openstack floating ip create $OPENSTACK_EXTERNAL_NETWORK --description "${CLUSTER_NAME}-apps" --format value --column floating_ip_address --port $INGRESS_PORT) 133 | else 134 | # attach the port 135 | openstack floating ip set --port $INGRESS_PORT $APPS_FLOATING_IP 136 | fi 137 | 138 | hosts="# Generated by shiftstack for $CLUSTER_NAME - Do not edit 139 | $FLOATING_IP api.${CLUSTER_NAME}.${BASE_DOMAIN} 140 | $APPS_FLOATING_IP console-openshift-console.apps.${CLUSTER_NAME}.${BASE_DOMAIN} 141 | $APPS_FLOATING_IP integrated-oauth-server-openshift-authentication.apps.${CLUSTER_NAME}.${BASE_DOMAIN} 142 | $APPS_FLOATING_IP oauth-openshift.apps.${CLUSTER_NAME}.${BASE_DOMAIN} 143 | $APPS_FLOATING_IP prometheus-k8s-openshift-monitoring.apps.${CLUSTER_NAME}.${BASE_DOMAIN} 144 | $APPS_FLOATING_IP grafana-openshift-monitoring.apps.${CLUSTER_NAME}.${BASE_DOMAIN} 145 | # End of $CLUSTER_NAME nodes" 146 | 147 | old_hosts=$(awk "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/" /etc/hosts) 148 | 149 | if [ "${hosts}" != "${old_hosts}" ]; then 150 | echo Updating hosts file 151 | sudo sed -i "/# Generated by shiftstack for $CLUSTER_NAME - Do not edit/,/# End of $CLUSTER_NAME nodes/d" /etc/hosts 152 | echo "$hosts" | sudo tee -a /etc/hosts 153 | fi 154 | fi 155 | -------------------------------------------------------------------------------- /server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 Red Hat, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -Eeuo pipefail 18 | 19 | print_help() { 20 | echo -e 'github.com/shiftstack/shiftstack-ci' 21 | echo -e 'Spin a server on OpenStack' 22 | echo 23 | echo -e 'Usage:' 24 | echo -e "\t${0} [-p] -f -i -e -k NAME" 25 | echo 26 | echo -e 'Required parameters:' 27 | echo -e '\t-f\tFlavor of the Compute instance.' 28 | echo -e '\t-i\tImage of the Compute instance.' 29 | echo -e '\t-e\tName or ID of the public network where to create the floating IP.' 30 | echo -e '\t-k\tName or ID of the SSH public key to add to the server.' 31 | echo -e '\tNAME: name to give to the OpenStack resources.' 32 | echo 33 | echo -e 'Optional parameters:' 34 | echo -e '\t-p\tDo not clean up the server after creation' 35 | echo -e '\t\t(will print a cleanup script instead of executing it).' 36 | } 37 | 38 | declare \ 39 | persistent='' \ 40 | server_flavor='' \ 41 | server_image='' \ 42 | key_name='' \ 43 | external_network='external' 44 | while getopts pf:i:e:k:h opt; do 45 | case "$opt" in 46 | p) persistent='yes' ;; 47 | f) server_flavor="$OPTARG" ;; 48 | i) server_image="$OPTARG" ;; 49 | e) external_network="$OPTARG" ;; 50 | k) key_name="$OPTARG" ;; 51 | h) print_help; exit 0 ;; 52 | *) exit 1 ;; 53 | esac 54 | done 55 | shift "$((OPTIND-1))" 56 | declare -r name="${1:?This script requires one positional argument: the resource name}" 57 | readonly \ 58 | server_flavor \ 59 | server_image \ 60 | key_name \ 61 | external_network 62 | 63 | declare \ 64 | sg_id='' \ 65 | network_id='' \ 66 | subnet_id='' \ 67 | router_id='' \ 68 | port_id='' \ 69 | server_id='' \ 70 | fip_id='' 71 | 72 | cleanup() { 73 | >&2 echo 74 | >&2 echo 75 | >&2 echo 'Starting the cleanup...' 76 | if [ -n "$fip_id" ]; then 77 | openstack floating ip delete "$fip_id" || >&2 echo "Failed to delete FIP $fip_id" 78 | fi 79 | if [ -n "$server_id" ]; then 80 | openstack server delete "$server_id" || >&2 echo "Failed to delete server $server_id" 81 | fi 82 | if [ -n "$port_id" ]; then 83 | openstack port delete "$port_id" || >&2 echo "Failed to delete port $port_id" 84 | fi 85 | if [ -n "$router_id" ]; then 86 | openstack router remove subnet "$router_id" "$subnet_id" || >&2 echo 'Failed to remove subnet from router' 87 | openstack router delete "$router_id" || >&2 echo "Failed to delete router $router_id" 88 | fi 89 | if [ -n "$subnet_id" ]; then 90 | openstack subnet delete "$subnet_id" || >&2 echo "Failed to delete subnet $subnet_id" 91 | fi 92 | if [ -n "$network_id" ]; then 93 | openstack network delete "$network_id" || >&2 echo "Failed to delete network $network_id" 94 | fi 95 | if [ -n "$sg_id" ]; then 96 | openstack security group delete "$sg_id" || >&2 echo "Failed to delete security group $sg_id" 97 | fi 98 | >&2 echo 'Cleanup done.' 99 | } 100 | 101 | trap cleanup EXIT 102 | 103 | print_cleanup_script() { 104 | cat <&2 echo "Failed to delete FIP $fip_id" 107 | openstack server delete "$server_id" || >&2 echo "Failed to delete server $server_id" 108 | openstack port delete "$port_id" || >&2 echo "Failed to delete port $port_id" 109 | openstack router remove subnet "$router_id" "$subnet_id" || >&2 echo 'Failed to remove subnet from router' 110 | openstack router delete "$router_id" || >&2 echo "Failed to delete router $router_id" 111 | openstack subnet delete "$subnet_id" || >&2 echo "Failed to delete subnet $subnet_id" 112 | openstack network delete "$network_id" || >&2 echo "Failed to delete network $network_id" 113 | openstack security group delete "$sg_id" || >&2 echo "Failed to delete security group $sg_id" 114 | EOF 115 | 116 | } 117 | 118 | sg_id="$(openstack security group create -f value -c id "$name")" 119 | >&2 echo "Created security group ${sg_id}" 120 | openstack security group rule create --ingress --protocol tcp --dst-port 22 --description "${name} SSH" "$sg_id" >/dev/null 121 | openstack security group rule create --ingress --protocol icmp --description "${name} ingress ping" "$sg_id" >/dev/null 122 | openstack security group rule create --ingress --protocol tcp --dst-port 80 --description "${name} ingress HTTP" "$sg_id" >/dev/null 123 | >&2 echo 'Security group rules created.' 124 | 125 | network_id="$(openstack network create -f value -c id "$name")" 126 | >&2 echo "Created network ${network_id}" 127 | 128 | subnet_id="$(openstack subnet create -f value -c id \ 129 | --network "$network_id" \ 130 | --subnet-range '172.16.0.0/24' \ 131 | --dns-nameserver '1.1.1.1' \ 132 | "$name")" 133 | >&2 echo "Created subnet ${subnet_id}" 134 | 135 | router_id="$(openstack router create -f value -c id \ 136 | "$name")" 137 | >&2 echo "Created router ${router_id}" 138 | openstack router add subnet "$router_id" "$subnet_id" 139 | openstack router set --external-gateway "$external_network" "$router_id" 140 | 141 | port_id="$(openstack port create -f value -c id \ 142 | --network "$network_id" \ 143 | --security-group "$sg_id" \ 144 | "$name")" 145 | >&2 echo "Created port ${port_id}" 146 | 147 | server_id="$(openstack server create -f value -c id \ 148 | --image "$server_image" \ 149 | --flavor "$server_flavor" \ 150 | --nic "port-id=$port_id" \ 151 | --security-group "$sg_id" \ 152 | --key-name "$key_name" \ 153 | "$name")" 154 | >&2 echo "Created server ${server_id}" 155 | 156 | fip_id="$(openstack floating ip create -f value -c id \ 157 | --description "$name" \ 158 | "$external_network")" 159 | >&2 echo "Created floating IP ${fip_id} $(openstack floating ip show -f value -c floating_ip_address "$fip_id")" 160 | openstack server add floating ip "$server_id" "$fip_id" 161 | 162 | if [ "$persistent" == 'yes' ]; then 163 | >&2 echo "Server created." 164 | trap true EXIT 165 | print_cleanup_script 166 | else 167 | >&2 echo "Server created. Press ENTER to tear down." 168 | read pause 169 | fi 170 | -------------------------------------------------------------------------------- /ci-dns/CI-DNS.yml: -------------------------------------------------------------------------------- 1 | passwd: 2 | users: 3 | - name: core 4 | ssh_authorized_keys: 5 | - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1qB1X9H9wDTT5J88nfeXtHBPAaRyIqe2rnF7bgqc4wpXpdSoxOX18K/45tT9sYOHU/63DfmQdpqUPso3Ql3uBzzW78np4Qa6HlGTynpOSqn7J3UwFdMD0/5EocqsEYfdQsjHCYT2arGvBWT2b4huxq9ke2WqXKUVEbZHpgSrR9dGQrM8xL1vmF5wcVTS6f5W0vq/x7YlJiIKtWUplV302DVFeLAXiDA+f6cVcd4q3NI07Py00sOU3YI3jYpPWxTMTj2R5k1bn+CbXqi5RfV/L+JLXq4XCAT7b/mHkSsXZC7Kn6s92oY930U5dSaYSZWVz54Q9wwOZYmdAoOKsGwwiQ== m.andre@redhat.com 6 | - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1HTJjdVoE1+O5Qieh4KvT3wHUP85lZzYTfaeE0tBdeHvSKZDonQQfYoMzkdwKEfV8Bgivd8nAYDZnFKqTF2rLvQkB4XuuZYdzwJEiXmW3GQpu3xTFDA9KdLfbuYqW/IlbjaGT5TiFSmDDErzhwlz2T5xKd2PsHM+URpctSgYlcIZPeW7Gj02dyyqF6TPJ93/VQEtBhLCwSh4cZOA+bkV0ghgcD6tyqyiM3MSrldEdy7098xXrOW0Lz1luHK+p5/vVsS2Uowd7yVAcFuHaG4/YTDpg/zIWdH/WJ85k4Pq2BmEwKr5G+Zmnqo4h17gfwaxPJtL9UorLSuaA/l5RPt7cQ== tsedovic@redhat.com 7 | - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsboPPbyMRqyh1mchlrX8t3jHp6MWaOm6DEA55PJ8YwSHbzgabU8x/X6fXYIppne0570cvtQW4NZyURWjb6y5AANwRtNOVz5lsxC0tgPLOMKzyopG/fZc8tsqH0rMzwPghEIH4a7XK16MDCyOdK5va3S3VVupCo5SYjimxYBC1EinXG3brhYe7500S0E/U8hn+26W2f2o8bS2Z3KoUweAsyENVXH5Y/m+ia5g2JbUa132AVEtWnhhQpbZkskpbr2MqsjpBIchOp5mOfqElEGzeRjjn2Kd8yZov11cKKeYwGoKSPQHvjK6E1t+LYRA1UxTmyNy4M4gPfIBncDm3pHIz egarcia@emilio 8 | - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+yNMzUrQXa0EOfv+WJtfmLO1WdoOaD47G9qwllSUc4GPRkYzkTNdxcEPrR3XBR94ctOeWOHZ/w7ymhvwK5LLsoNBK+WgRz/mg8oHcii2GoL0fNojdwUMyFMIJxJT+iwjF/omyhyrW/aLAztAKRO7BdOkNlXMAAcMxKzQtFqdZm09ghoImu3BPYUTyDKHMp+t0P1d7mkHdd719oDfMf+5miHxQeJZJCWAsGwroN7k8a46rvezDHEygBsDAF2ZpS2iGMABos/vTp1oyHkCgCqc3rM0OoKqcKB5iQ9Qaqi5ung08BXP/PHfVynXzdGMjTh4w+6jiMw7Dx2GrQIJsDolKQ== dprince@redhat.com 9 | - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpE2mGXMLZLBpWYMhO1Kz85FryqgD9zGStgTrY1x1Fspyjk4la9v2AYWsTCLISlNne3CdhaRmKjhYo7xdW9px8JCbPwtXqbCjOEuKsuHCtlbn+6ubZsJaYkImYAq3EEsi0cXMUCutrMPzMZaMCiaTIUhOXj+f1GY6zqVZlK2thJO9tzj5vAx1leWlwdn6CBM7ikXCQ6PVvqofki2pdV7V/HF3dmNCg1196/o8yH5x+ItithPJCvXytlIzi+5jy7YqGnei5jDUzqf0ZMS2OnJ7IkTz3vx322g3SUET/lYoFO5bjYbhAsLc83WM4Yvaw9FCEZCzKxMBQXK91oGH5siHT mfedosin@redhat.com 10 | - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== pprinett@redhat.com 11 | storage: 12 | files: 13 | - path: /etc/iptables.rules 14 | filesystem: root 15 | mode: 0644 16 | contents: 17 | inline: | 18 | *filter 19 | :INPUT ACCEPT [0:0] 20 | :FORWARD ACCEPT [0:0] 21 | :OUTPUT ACCEPT [0:0] 22 | -A INPUT -p udp --dport 53 -m string --string massopen --algo bm -j ACCEPT 23 | -A INPUT -p udp --dport 53 -m string --string shiftstack --algo bm -j ACCEPT 24 | -A INPUT -p udp --dport 53 -m string --string openshift --algo bm -j ACCEPT 25 | -A INPUT -p udp --dport 53 -m string --string googleapis --algo bm -j ACCEPT 26 | -A INPUT -p udp --dport 53 -m string --string boskos --algo bm -j ACCEPT 27 | -A INPUT -p udp --dport 53 -s 192.168.23.0/24 -j ACCEPT -m comment --comment "accept DNS queries from internal network" 28 | -A INPUT -p udp --dport 53 -j DROP -m comment --comment "drop all DNS queries from outside" 29 | COMMIT 30 | - path: /etc/coredns/dynamic-update.py 31 | filesystem: root 32 | mode: 0644 33 | contents: 34 | inline: | 35 | import http.server 36 | import json 37 | import logging 38 | import os 39 | 40 | # Edit these to suit your needs: 41 | PORT = 8080 42 | DOMAIN = "shiftstack.ci" 43 | COREDB_FILE = "/etc/coredns/db.{}".format(DOMAIN) 44 | LOG_FILE = "/var/log/dynamic-dns-updater.log" 45 | 46 | 47 | # You should probably not touch these unless you want to hardcode some records 48 | COREDB_TEMPLATE = """ 49 | $ORIGIN {domain}. 50 | @ 3600 IN SOA {domain}. hostmaster ( 51 | {serial} ; serial 52 | 7200 ; refresh (2 hours) 53 | 3600 ; retry (1 hour) 54 | 1209600 ; expire (2 weeks) 55 | 3600 ; minimum (1 hour) 56 | ) 57 | 58 | {entries} 59 | """ 60 | ENTRIES = {} 61 | SERIAL_NUMBER = 0 62 | 63 | 64 | def build_coredb_file(domain, serial_number, entries): 65 | formatted_entries = '\n'.join("{} IN A {}".format(name, ip) for name, ip 66 | in entries.items()) 67 | return COREDB_TEMPLATE.format(domain=domain, serial=serial_number, 68 | entries=formatted_entries) 69 | 70 | 71 | class ServerHandler(http.server.SimpleHTTPRequestHandler): 72 | def do_POST(self): 73 | content_len = int(self.headers.get('content-length', 0)) 74 | post_body = self.rfile.read(content_len) 75 | body = "" 76 | client_address = self.client_address[0] 77 | try: 78 | body = json.loads(post_body) 79 | except Exception: 80 | self.send_response(422) 81 | self.end_headers() 82 | logging.warning("Invalid JSON from {}".format(client_address)) 83 | return 84 | self.send_response(200) 85 | self.end_headers() 86 | 87 | if self.path == "/add": 88 | self.process_add(body, client_address) 89 | elif self.path == "/remove": 90 | self.process_remove(body, client_address) 91 | 92 | def write_db_file(self): 93 | global ENTRIES 94 | global SERIAL_NUMBER 95 | global DOMAIN 96 | SERIAL_NUMBER += 1 97 | db = build_coredb_file(DOMAIN, SERIAL_NUMBER, ENTRIES) 98 | logging.info("Writing version {} to file {}".format(SERIAL_NUMBER, 99 | COREDB_FILE)) 100 | with open(COREDB_FILE, 'w') as f: 101 | f.write(db) 102 | 103 | def iptables_rule(self, address, comment): 104 | return "INPUT -p udp --dport 53 -j ACCEPT -s {} " \ 105 | "-m comment --comment '{}'".format(address, comment) 106 | 107 | def add_iptables_rule(self, address, comment): 108 | rule = self.iptables_rule(address, comment) 109 | self.ensure_iptables_rule("insert", rule) 110 | 111 | def remove_iptables_rule(self, address, comment): 112 | rule = self.iptables_rule(address, comment) 113 | self.ensure_iptables_rule("delete", rule) 114 | 115 | def ensure_iptables_rule(self, command, rule): 116 | # iptables --check returns 0 if the rule exists 117 | # It also generates harmless "iptables: Bad rule (does a matching rule 118 | # exist in that chain?)." comments in the logs when the rule does not 119 | # yet exist. 120 | if (command == 'insert' and 121 | os.system("/sbin/iptables --check {}".format(rule)) == 0): 122 | return 123 | 124 | os.system("/sbin/iptables --{} {}".format(command, rule)) 125 | 126 | def process_add(self, body, client_address): 127 | global ENTRIES 128 | if body.get('cluster_name') and \ 129 | (body.get('lb_fip') or body.get('apps_fip')): 130 | logging.info("Adding entries for {}".format(body['cluster_name'])) 131 | if body.get('lb_fip'): 132 | ENTRIES["api.{}".format(body['cluster_name'])] = body['lb_fip'] 133 | if body.get('apps_fip'): 134 | ENTRIES["*.apps.{}".format(body['cluster_name'])] = \ 135 | body['apps_fip'] 136 | self.write_db_file() 137 | self.add_iptables_rule(client_address, body['cluster_name']) 138 | else: 139 | logging.warning("Invalid JSON from {}".format(client_address)) 140 | 141 | def process_remove(self, body, client_address): 142 | global ENTRIES 143 | if body.get('cluster_name'): 144 | if "api.{}".format(body['cluster_name']) in ENTRIES: 145 | del ENTRIES["api.{}".format(body['cluster_name'])] 146 | if "*.apps.{}".format(body['cluster_name']) in ENTRIES: 147 | del ENTRIES["*.apps.{}".format(body['cluster_name'])] 148 | logging.info("Removing entries for {}".format( 149 | body['cluster_name'])) 150 | self.write_db_file() 151 | self.remove_iptables_rule(client_address, body['cluster_name']) 152 | else: 153 | logging.warning("Invalid JSON from {}".format(client_address)) 154 | 155 | 156 | if __name__ == '__main__': 157 | logging.basicConfig(filename=LOG_FILE, 158 | format='%(asctime)s - %(levelname)s - %(message)s', 159 | level=logging.DEBUG) 160 | with http.server.HTTPServer(("", PORT), ServerHandler) as httpd: 161 | logging.info("Serving at port %s", PORT) 162 | httpd.serve_forever() 163 | 164 | - path: /etc/coredns/Corefile 165 | filesystem: root 166 | mode: 0644 167 | contents: 168 | inline: | 169 | . { 170 | log 171 | errors 172 | 173 | hosts { 174 | # This is the IP address of the boskos service inside the CI cluster 175 | 172.30.131.17 boskos.ci 176 | fallthrough 177 | } 178 | 179 | forward . /etc/resolv.conf { 180 | except shiftstack.ci 181 | } 182 | } 183 | 184 | shiftstack.ci { 185 | log 186 | errors 187 | 188 | file /etc/coredns/db.shiftstack.ci { 189 | reload 10s 190 | } 191 | } 192 | 193 | - path: /etc/coredns/db.shiftstack.ci 194 | filesystem: root 195 | mode: 0644 196 | contents: 197 | inline: | 198 | $ORIGIN shiftstack.ci. 199 | @ 3600 IN SOA dns.shiftstack.ci. hostmaster ( 200 | 2017042752 ; serial 201 | 7200 ; refresh (2 hours) 202 | 3600 ; retry (1 hour) 203 | 1209600 ; expire (2 weeks) 204 | 3600 ; minimum (1 hour) 205 | ) 206 | 207 | 208 | systemd: 209 | units: 210 | - name: iptables.service 211 | enabled: true 212 | contents: | 213 | [Unit] 214 | Description=Firewall 215 | After=network.target 216 | 217 | [Service] 218 | Type=oneshot 219 | RemainAfterExit=yes 220 | ExecStart=/bin/sh -c "/sbin/iptables-restore < /etc/iptables.rules" 221 | 222 | [Install] 223 | WantedBy=multi-user.target 224 | - name: ci-dns.service 225 | enabled: true 226 | contents: | 227 | [Unit] 228 | Description=CI DNS 229 | 230 | [Service] 231 | ExecStart=/bin/podman run --rm -i -t -m 128m --net host --cap-add=NET_ADMIN -v /etc/coredns:/etc/coredns:Z openshift/origin-coredns:v4.0 -conf /etc/coredns/Corefile 232 | Restart=always 233 | RestartSec=10 234 | 235 | [Install] 236 | WantedBy=multi-user.target 237 | - name: dynamic-dns-updater.service 238 | enabled: true 239 | contents: | 240 | [Unit] 241 | Description=Dynamic DNS updater 242 | 243 | [Service] 244 | ExecStart=/usr/libexec/platform-python /etc/coredns/dynamic-update.py 245 | Restart=always 246 | RestartSec=10 247 | 248 | [Install] 249 | WantedBy=multi-user.target 250 | -------------------------------------------------------------------------------- /ci-dns/CI-DNS.ign: -------------------------------------------------------------------------------- 1 | {"ignition":{"config":{},"security":{"tls":{}},"timeouts":{},"version":"2.2.0"},"networkd":{},"passwd":{"users":[{"name":"core","sshAuthorizedKeys":["ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1qB1X9H9wDTT5J88nfeXtHBPAaRyIqe2rnF7bgqc4wpXpdSoxOX18K/45tT9sYOHU/63DfmQdpqUPso3Ql3uBzzW78np4Qa6HlGTynpOSqn7J3UwFdMD0/5EocqsEYfdQsjHCYT2arGvBWT2b4huxq9ke2WqXKUVEbZHpgSrR9dGQrM8xL1vmF5wcVTS6f5W0vq/x7YlJiIKtWUplV302DVFeLAXiDA+f6cVcd4q3NI07Py00sOU3YI3jYpPWxTMTj2R5k1bn+CbXqi5RfV/L+JLXq4XCAT7b/mHkSsXZC7Kn6s92oY930U5dSaYSZWVz54Q9wwOZYmdAoOKsGwwiQ== m.andre@redhat.com","ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1HTJjdVoE1+O5Qieh4KvT3wHUP85lZzYTfaeE0tBdeHvSKZDonQQfYoMzkdwKEfV8Bgivd8nAYDZnFKqTF2rLvQkB4XuuZYdzwJEiXmW3GQpu3xTFDA9KdLfbuYqW/IlbjaGT5TiFSmDDErzhwlz2T5xKd2PsHM+URpctSgYlcIZPeW7Gj02dyyqF6TPJ93/VQEtBhLCwSh4cZOA+bkV0ghgcD6tyqyiM3MSrldEdy7098xXrOW0Lz1luHK+p5/vVsS2Uowd7yVAcFuHaG4/YTDpg/zIWdH/WJ85k4Pq2BmEwKr5G+Zmnqo4h17gfwaxPJtL9UorLSuaA/l5RPt7cQ== tsedovic@redhat.com","ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDsboPPbyMRqyh1mchlrX8t3jHp6MWaOm6DEA55PJ8YwSHbzgabU8x/X6fXYIppne0570cvtQW4NZyURWjb6y5AANwRtNOVz5lsxC0tgPLOMKzyopG/fZc8tsqH0rMzwPghEIH4a7XK16MDCyOdK5va3S3VVupCo5SYjimxYBC1EinXG3brhYe7500S0E/U8hn+26W2f2o8bS2Z3KoUweAsyENVXH5Y/m+ia5g2JbUa132AVEtWnhhQpbZkskpbr2MqsjpBIchOp5mOfqElEGzeRjjn2Kd8yZov11cKKeYwGoKSPQHvjK6E1t+LYRA1UxTmyNy4M4gPfIBncDm3pHIz egarcia@emilio","ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA+yNMzUrQXa0EOfv+WJtfmLO1WdoOaD47G9qwllSUc4GPRkYzkTNdxcEPrR3XBR94ctOeWOHZ/w7ymhvwK5LLsoNBK+WgRz/mg8oHcii2GoL0fNojdwUMyFMIJxJT+iwjF/omyhyrW/aLAztAKRO7BdOkNlXMAAcMxKzQtFqdZm09ghoImu3BPYUTyDKHMp+t0P1d7mkHdd719oDfMf+5miHxQeJZJCWAsGwroN7k8a46rvezDHEygBsDAF2ZpS2iGMABos/vTp1oyHkCgCqc3rM0OoKqcKB5iQ9Qaqi5ung08BXP/PHfVynXzdGMjTh4w+6jiMw7Dx2GrQIJsDolKQ== dprince@redhat.com","ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpE2mGXMLZLBpWYMhO1Kz85FryqgD9zGStgTrY1x1Fspyjk4la9v2AYWsTCLISlNne3CdhaRmKjhYo7xdW9px8JCbPwtXqbCjOEuKsuHCtlbn+6ubZsJaYkImYAq3EEsi0cXMUCutrMPzMZaMCiaTIUhOXj+f1GY6zqVZlK2thJO9tzj5vAx1leWlwdn6CBM7ikXCQ6PVvqofki2pdV7V/HF3dmNCg1196/o8yH5x+ItithPJCvXytlIzi+5jy7YqGnei5jDUzqf0ZMS2OnJ7IkTz3vx322g3SUET/lYoFO5bjYbhAsLc83WM4Yvaw9FCEZCzKxMBQXK91oGH5siHT mfedosin@redhat.com","ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC/Zc+pyRoKWVS1CVx2soRe7Ia7RGkASpXZE495H2XuS3gF4Vb9JdATkJ4NURmAQhUN8TYCbfqTcf2Fpm/5mtG6Dn8Avua1mXgNRvrufVYBvWkOn9qPEYkwELSG0WcqjpISwsKRAU0d7Mcqo0aDmp/wpgbXHCBG03Q8w0uhRTdI7jEj/EzatbtkgUJnE79OHUImxdG+11oKH0Ul2lQlSo+pMa0fwS3GrHKIxxZmMckSpT+gua0AttuGpr+JYIZKNkoWn7bMqpYpJAlKxjzaB6ympaIAOgd/CxXnXPzc8ntIm/MubDUbGzo7dpq39MmxtWb1bahS/zeyFq0ZR43FbHexZyj21PiurtFOXl93r+wgBLBcVjBogi23p8i+SrjOVb+nJJ5XEUaLDYYE7T4xnrmT/T0ODQQbh6W+F+/mCSwOpRsZV0+FYcWg34InQM177eBweAv5Lwtct6B0xzCCXYpNTjWpBUe46dP7FO0ltzD57CGglRyx7whff96Og7Zx61/YfR/zrfI4NYiP+4EbiN24NuTn0DvND/anCpvA1Zpsd7bNMvL9YrlCRD2lfcQl3p6Kqi48jLNpqjEMYEmgYzzGjE1hFuVqdjY63bAmD3+NPlfARsgbMiPpLAmb3nE5FTCWktUTE8fnoWIojUYm7/4HoVQlwWxRhLKji5NiJGMgYw== pprinett@redhat.com"]}]},"storage":{"files":[{"filesystem":"root","path":"/etc/iptables.rules","contents":{"source":"data:,*filter%0A%3AINPUT%20ACCEPT%20%5B0%3A0%5D%0A%3AFORWARD%20ACCEPT%20%5B0%3A0%5D%0A%3AOUTPUT%20ACCEPT%20%5B0%3A0%5D%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-m%20string%20--string%20massopen%20--algo%20bm%20-j%20ACCEPT%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-m%20string%20--string%20shiftstack%20--algo%20bm%20-j%20ACCEPT%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-m%20string%20--string%20openshift%20--algo%20bm%20-j%20ACCEPT%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-m%20string%20--string%20googleapis%20--algo%20bm%20-j%20ACCEPT%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-m%20string%20--string%20boskos%20--algo%20bm%20-j%20ACCEPT%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-s%20192.168.23.0%2F24%20-j%20ACCEPT%20-m%20comment%20--comment%20%22accept%20DNS%20queries%20from%20internal%20network%22%0A-A%20INPUT%20-p%20udp%20--dport%2053%20-j%20DROP%20-m%20comment%20--comment%20%22drop%20all%20DNS%20queries%20from%20outside%22%0ACOMMIT%0A","verification":{}},"mode":420},{"filesystem":"root","path":"/etc/coredns/dynamic-update.py","contents":{"source":"data:,import%20http.server%0Aimport%20json%0Aimport%20logging%0Aimport%20os%0A%0A%23%20Edit%20these%20to%20suit%20your%20needs%3A%0APORT%20%3D%208080%0ADOMAIN%20%3D%20%22shiftstack.ci%22%0ACOREDB_FILE%20%3D%20%22%2Fetc%2Fcoredns%2Fdb.%7B%7D%22.format(DOMAIN)%0ALOG_FILE%20%3D%20%22%2Fvar%2Flog%2Fdynamic-dns-updater.log%22%0A%0A%0A%23%20You%20should%20probably%20not%20touch%20these%20unless%20you%20want%20to%20hardcode%20some%20records%0ACOREDB_TEMPLATE%20%3D%20%22%22%22%0A%24ORIGIN%20%7Bdomain%7D.%0A%40%20%20%20%203600%20IN%20SOA%20%7Bdomain%7D.%20hostmaster%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bserial%7D%20%3B%20serial%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%207200%20%20%20%20%20%20%20%3B%20refresh%20(2%20hours)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203600%20%20%20%20%20%20%20%3B%20retry%20(1%20hour)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201209600%20%20%20%20%3B%20expire%20(2%20weeks)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203600%20%20%20%20%20%20%20%3B%20minimum%20(1%20hour)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%7Bentries%7D%0A%22%22%22%0AENTRIES%20%3D%20%7B%7D%0ASERIAL_NUMBER%20%3D%200%0A%0A%0Adef%20build_coredb_file(domain%2C%20serial_number%2C%20entries)%3A%0A%20%20%20%20formatted_entries%20%3D%20'%5Cn'.join(%22%7B%7D%20IN%20A%20%7B%7D%22.format(name%2C%20ip)%20for%20name%2C%20ip%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20in%20entries.items())%0A%20%20%20%20return%20COREDB_TEMPLATE.format(domain%3Ddomain%2C%20serial%3Dserial_number%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20entries%3Dformatted_entries)%0A%0A%0Aclass%20ServerHandler(http.server.SimpleHTTPRequestHandler)%3A%0A%20%20%20%20def%20do_POST(self)%3A%0A%20%20%20%20%20%20%20%20content_len%20%3D%20int(self.headers.get('content-length'%2C%200))%0A%20%20%20%20%20%20%20%20post_body%20%3D%20self.rfile.read(content_len)%0A%20%20%20%20%20%20%20%20body%20%3D%20%22%22%0A%20%20%20%20%20%20%20%20client_address%20%3D%20self.client_address%5B0%5D%0A%20%20%20%20%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20body%20%3D%20json.loads(post_body)%0A%20%20%20%20%20%20%20%20except%20Exception%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.send_response(422)%0A%20%20%20%20%20%20%20%20%20%20%20%20self.end_headers()%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.warning(%22Invalid%20JSON%20from%20%7B%7D%22.format(client_address))%0A%20%20%20%20%20%20%20%20%20%20%20%20return%0A%20%20%20%20%20%20%20%20self.send_response(200)%0A%20%20%20%20%20%20%20%20self.end_headers()%0A%0A%20%20%20%20%20%20%20%20if%20self.path%20%3D%3D%20%22%2Fadd%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.process_add(body%2C%20client_address)%0A%20%20%20%20%20%20%20%20elif%20self.path%20%3D%3D%20%22%2Fremove%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.process_remove(body%2C%20client_address)%0A%0A%20%20%20%20def%20write_db_file(self)%3A%0A%20%20%20%20%20%20%20%20global%20ENTRIES%0A%20%20%20%20%20%20%20%20global%20SERIAL_NUMBER%0A%20%20%20%20%20%20%20%20global%20DOMAIN%0A%20%20%20%20%20%20%20%20SERIAL_NUMBER%20%2B%3D%201%0A%20%20%20%20%20%20%20%20db%20%3D%20build_coredb_file(DOMAIN%2C%20SERIAL_NUMBER%2C%20ENTRIES)%0A%20%20%20%20%20%20%20%20logging.info(%22Writing%20version%20%7B%7D%20to%20file%20%7B%7D%22.format(SERIAL_NUMBER%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20COREDB_FILE))%0A%20%20%20%20%20%20%20%20with%20open(COREDB_FILE%2C%20'w')%20as%20f%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20f.write(db)%0A%0A%20%20%20%20def%20iptables_rule(self%2C%20address%2C%20comment)%3A%0A%20%20%20%20%20%20%20%20return%20%22INPUT%20-p%20udp%20--dport%2053%20-j%20ACCEPT%20-s%20%7B%7D%20%22%20%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22-m%20comment%20--comment%20'%7B%7D'%22.format(address%2C%20comment)%0A%0A%20%20%20%20def%20add_iptables_rule(self%2C%20address%2C%20comment)%3A%0A%20%20%20%20%20%20%20%20rule%20%3D%20self.iptables_rule(address%2C%20comment)%0A%20%20%20%20%20%20%20%20self.ensure_iptables_rule(%22insert%22%2C%20rule)%0A%0A%20%20%20%20def%20remove_iptables_rule(self%2C%20address%2C%20comment)%3A%0A%20%20%20%20%20%20%20%20rule%20%3D%20self.iptables_rule(address%2C%20comment)%0A%20%20%20%20%20%20%20%20self.ensure_iptables_rule(%22delete%22%2C%20rule)%0A%0A%20%20%20%20def%20ensure_iptables_rule(self%2C%20command%2C%20rule)%3A%0A%20%20%20%20%20%20%20%20%23%20iptables%20--check%20returns%200%20if%20the%20rule%20exists%0A%20%20%20%20%20%20%20%20%23%20It%20also%20generates%20harmless%20%22iptables%3A%20Bad%20rule%20(does%20a%20matching%20rule%0A%20%20%20%20%20%20%20%20%23%20exist%20in%20that%20chain%3F).%22%20comments%20in%20the%20logs%20when%20the%20rule%20does%20not%0A%20%20%20%20%20%20%20%20%23%20yet%20exist.%0A%20%20%20%20%20%20%20%20if%20(command%20%3D%3D%20'insert'%20and%0A%20%20%20%20%20%20%20%20%20%20os.system(%22%2Fsbin%2Fiptables%20--check%20%7B%7D%22.format(rule))%20%3D%3D%200)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%0A%0A%20%20%20%20%20%20%20%20os.system(%22%2Fsbin%2Fiptables%20--%7B%7D%20%7B%7D%22.format(command%2C%20rule))%0A%0A%20%20%20%20def%20process_add(self%2C%20body%2C%20client_address)%3A%0A%20%20%20%20%20%20%20%20global%20ENTRIES%0A%20%20%20%20%20%20%20%20if%20body.get('cluster_name')%20and%20%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(body.get('lb_fip')%20or%20body.get('apps_fip'))%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.info(%22Adding%20entries%20for%20%7B%7D%22.format(body%5B'cluster_name'%5D))%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20body.get('lb_fip')%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ENTRIES%5B%22api.%7B%7D%22.format(body%5B'cluster_name'%5D)%5D%20%3D%20body%5B'lb_fip'%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20body.get('apps_fip')%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ENTRIES%5B%22*.apps.%7B%7D%22.format(body%5B'cluster_name'%5D)%5D%20%3D%20%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20body%5B'apps_fip'%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20self.write_db_file()%0A%20%20%20%20%20%20%20%20%20%20%20%20self.add_iptables_rule(client_address%2C%20body%5B'cluster_name'%5D)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.warning(%22Invalid%20JSON%20from%20%7B%7D%22.format(client_address))%0A%0A%20%20%20%20def%20process_remove(self%2C%20body%2C%20client_address)%3A%0A%20%20%20%20%20%20%20%20global%20ENTRIES%0A%20%20%20%20%20%20%20%20if%20body.get('cluster_name')%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%22api.%7B%7D%22.format(body%5B'cluster_name'%5D)%20in%20ENTRIES%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20del%20ENTRIES%5B%22api.%7B%7D%22.format(body%5B'cluster_name'%5D)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%22*.apps.%7B%7D%22.format(body%5B'cluster_name'%5D)%20in%20ENTRIES%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20del%20ENTRIES%5B%22*.apps.%7B%7D%22.format(body%5B'cluster_name'%5D)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.info(%22Removing%20entries%20for%20%7B%7D%22.format(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20body%5B'cluster_name'%5D))%0A%20%20%20%20%20%20%20%20%20%20%20%20self.write_db_file()%0A%20%20%20%20%20%20%20%20%20%20%20%20self.remove_iptables_rule(client_address%2C%20body%5B'cluster_name'%5D)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.warning(%22Invalid%20JSON%20from%20%7B%7D%22.format(client_address))%0A%0A%0Aif%20__name__%20%3D%3D%20'__main__'%3A%0A%20%20%20%20logging.basicConfig(filename%3DLOG_FILE%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20format%3D'%25(asctime)s%20-%20%25(levelname)s%20-%20%25(message)s'%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20level%3Dlogging.DEBUG)%0A%20%20%20%20with%20http.server.HTTPServer((%22%22%2C%20PORT)%2C%20ServerHandler)%20as%20httpd%3A%0A%20%20%20%20%20%20%20%20logging.info(%22Serving%20at%20port%20%25s%22%2C%20PORT)%0A%20%20%20%20%20%20%20%20httpd.serve_forever()%0A","verification":{}},"mode":420},{"filesystem":"root","path":"/etc/coredns/Corefile","contents":{"source":"data:,.%20%7B%0A%20%20%20%20log%0A%20%20%20%20errors%0A%0A%20%20%20%20hosts%20%7B%0A%20%20%20%20%20%20%23%20This%20is%20the%20IP%20address%20of%20the%20boskos%20service%20inside%20the%20CI%20cluster%0A%20%20%20%20%20%20172.30.131.17%20boskos.ci%0A%20%20%20%20%20%20fallthrough%0A%20%20%20%20%7D%0A%0A%20%20%20%20forward%20.%20%2Fetc%2Fresolv.conf%20%7B%0A%20%20%20%20%20%20%20%20except%20shiftstack.ci%0A%20%20%20%20%7D%0A%7D%0A%0Ashiftstack.ci%20%7B%0A%20%20%20%20log%0A%20%20%20%20errors%0A%0A%20%20%20%20file%20%2Fetc%2Fcoredns%2Fdb.shiftstack.ci%20%7B%0A%20%20%20%20%20%20%20%20reload%2010s%0A%20%20%20%20%7D%0A%7D%0A","verification":{}},"mode":420},{"filesystem":"root","path":"/etc/coredns/db.shiftstack.ci","contents":{"source":"data:,%24ORIGIN%20shiftstack.ci.%0A%40%20%20%20%203600%20IN%20SOA%20dns.shiftstack.ci.%20hostmaster%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%202017042752%20%3B%20serial%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%207200%20%20%20%20%20%20%20%3B%20refresh%20(2%20hours)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203600%20%20%20%20%20%20%20%3B%20retry%20(1%20hour)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201209600%20%20%20%20%3B%20expire%20(2%20weeks)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%203600%20%20%20%20%20%20%20%3B%20minimum%20(1%20hour)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A","verification":{}},"mode":420}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=Firewall\nAfter=network.target\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/bin/sh -c \"/sbin/iptables-restore \u003c /etc/iptables.rules\"\n\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"iptables.service"},{"contents":"[Unit]\nDescription=CI DNS\n\n[Service]\nExecStart=/bin/podman run --rm -i -t -m 128m --net host --cap-add=NET_ADMIN -v /etc/coredns:/etc/coredns:Z openshift/origin-coredns:v4.0 -conf /etc/coredns/Corefile\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"ci-dns.service"},{"contents":"[Unit]\nDescription=Dynamic DNS updater\n\n[Service]\nExecStart=/usr/libexec/platform-python /etc/coredns/dynamic-update.py\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"dynamic-dns-updater.service"}]}} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------