diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-10-23 15:13:36 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-10-23 15:15:18 +0200 |
commit | 83edd3a996c506b6a1988d0c68214e9a849397d8 (patch) | |
tree | 480d540ba768ccbdb4d730c3a422164c846058f5 /controller/bin/dtf-get-machine.in | |
parent | 3d7b436102772e5e9e146e45e8d52210ce7498b5 (diff) | |
download | postgresql-setup-tests-83edd3a996c506b6a1988d0c68214e9a849397d8.tar.gz postgresql-setup-tests-83edd3a996c506b6a1988d0c68214e9a849397d8.tar.xz postgresql-setup-tests-83edd3a996c506b6a1988d0c68214e9a849397d8.zip |
controller: autoconfiscate
First part of converting controller to autoconf/automake solution.
* .gitignore: New gitignore; autotools ignores.
* Makefile.am: New file.
* get_machine: Renamed to template bin/dtf-get-machine.in.
* bin/dtf-get-machine.in: New template based on get_machine.
* run_remote: Renamed to template bin/dtf-run-remote.in.
* bin/dtf-run-remote.in: New binary template from run_remote.
* build: New bootstrap like helper script (git-only).
* configure.ac: New file.
* etc/dtf.sh.in: Likewise.
* ansible_helpers/wait-for-ssh: Renamed to
libexec/dtf-wait-for-ssh.
* share/dtf-controller/parse_credsfile: Reworked script for
parsing OS credentials.
* parse_credsfile: Moved to share/dtf-controller.
* libexec/dtf-wait-for-ssh: Renamed from wait-for-ssh.
* ansible/*: Moved into share/dtf-controller/ansible/*.
* share/dtf-controller/ansible/vars/generated-vars.yml.in: New
template file exporting configure-time variables into playbooks.
Diffstat (limited to 'controller/bin/dtf-get-machine.in')
-rw-r--r-- | controller/bin/dtf-get-machine.in | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/controller/bin/dtf-get-machine.in b/controller/bin/dtf-get-machine.in new file mode 100644 index 0000000..0d7c567 --- /dev/null +++ b/controller/bin/dtf-get-machine.in @@ -0,0 +1,87 @@ +#!/bin/bash + +die() { echo "$@" ; exit 1 ; } +info() { echo " * $@" ; } + +opt_openstack_instance=os1 +opt_distro=fedora +opt_distro_version=20 + +function show_help() +{ +cat <<EOHELP >&2 +Usage: $0 OPTION + +Script is aimed to help sysadmin. + +Options: + --distro=NAME Distro name, like fedora + --distro-version=VERSION E.g. 20 for Fedora 20 + --openstack-instance=ID + --name=NAME Name of the machine +EOHELP +test -n "$1" && exit "$1" +} + +boot() +( + set -o pipefail + nova boot "$1" --poll \ + --image "$2" \ + --flavor "$3" \ + --security-groups "$os_security_group" \ + --key-name "$os_keypair" \ + | grep "| id " | cut -d\| -f 3 | xargs -n 1 +) + +get_ip() +( + id="$1" + set -o pipefail + nova show "$id" | grep ' network ' \ + | cut -d\| -f 3 | cut -d, -f2 | xargs -n 1 +) + + +longopts="distro:,distro-version:,openstack-instance:,name:" +ARGS=$(getopt -o "" -l "help,$longopts" -n "$0" -- "$@") \ + || exit 1 +eval set -- "$ARGS" + +while true; do + case "$1" in + --distro|--distro-version|--openstack-instance|--name) + opt=$(sed -e 's/^--//' -e 's/[^[a-zA-Z0-9]/_/g'<<<"$1") + eval "opt_$opt=\"${2,,}\"" + shift 2 + ;; + + --help) + show_help 0 + ;; + + --) + shift + break; + esac +done + +. "@pkgdatadir@/parse_credsfile" "$opt_openstack_instance" || exit 1 +. ./config/os/"$opt_openstack_instance.sh" || exit 1 + +image_version=$opt_distro$opt_distro_version +image=${os_image_ids[$image_version]} +flavor=${os_flavor_ids[$image_version]} + +test -z "$image" && die "no image for '$image_version'" +test -z "$flavor" && die "no flavor for '$image_version'" +test -z "$opt_name" && opt_name="testing-$image" + +info "booting machine $image_version from $image" + +machine=$(boot "$opt_name" "$image" "$flavor") + +info "machine id: $machine" + +ip=$(get_ip "$machine") +info "ip: $ip" |