Add temporary key to OVB stack if undercloud is created

This will be used to access the "undercloud" or extra node if it was
created by the CI run.

Change-Id: Ib01a0b4ee76c033739ce9f7003070aa29714875e
This commit is contained in:
Juan Antonio Osorio Robles 2016-12-21 10:01:03 +02:00
parent 34796ff84d
commit 2726b2aee7
5 changed files with 29 additions and 3 deletions

View File

@ -5,6 +5,7 @@ ENVNUM=${1:-$(date +%s)}
NODECOUNT=${2:-2}
UCINSTANCE=${3:-}
CREATE_UNDERCLOUD=${4:-""}
SSH_KEY=${5:-""}
PROVISIONNET=provision-${ENVNUM}
PUBLICNET=public-${ENVNUM}
ENVFILE=env-${ENVNUM}.yaml
@ -19,9 +20,17 @@ fi
cd /opt/stack/openstack-virtual-baremetal/
if [ -n "$SSH_KEY" ]; then
echo "$SSH_KEY" > temp-key-$ENVNUM.pub
KEY_NAME="tripleo-ci-key-$ENVNUM"
openstack keypair create --public-key temp-key-$ENVNUM.pub $KEY_NAME
else
KEY_NAME="tripleo-cd-admins"
fi
/bin/cp --remove-destination templates/env.yaml.example $ENVFILE
sed -i -e "s/bmc_image:.*/bmc_image: bmc-template/" $ENVFILE
sed -i -e "s/key_name:.*/key_name: tripleo-cd-admins/" $ENVFILE
sed -i -e "s/key_name:.*/key_name: ${KEY_NAME}/" $ENVFILE
sed -i -e "s/node_count:.*/node_count: ${NODECOUNT}/" $ENVFILE
sed -i -e "s/os_auth_url:.*/os_auth_url: ${OS_AUTH_URL//\//\/}/" $ENVFILE
sed -i -e "s/os_password:.*/os_password: $OS_PASSWORD/" $ENVFILE

View File

@ -7,6 +7,7 @@ PUBLICNET=public-${ENVNUM}
ENVFILE=env-${ENVNUM}.yaml
rm -f /opt/stack/openstack-virtual-baremetal/$ENVFILE
rm -f /opt/stack/openstack-virtual-baremetal/temp-key-$ENVNUM.pub
source /etc/nodepoolrc
@ -23,6 +24,9 @@ delete_ports $SUBNETID
SUBNETID=$(neutron subnet-show $PROVISIONNET | awk '$2=="id" {print $4}')
delete_ports $SUBNETID
# If there was a keypair for this specific run, delete it.
openstack keypair delete "tripleo-ci-key-$ENVNUM" || true
# NOTE(bnemec): I'm periodically seeing the stack-delete fail to connect to
# Heat. It looks like a transient network issue, so let's just retry when it happens.
for i in $(seq 10); do

View File

@ -130,7 +130,8 @@ class TEWorkerThread(threading.Thread):
self.num,
arguments.get("envsize","2"),
arguments.get("ucinstance",""),
arguments.get("create_undercloud", "")],
arguments.get("create_undercloud", ""),
arguments.get("ssh_key", "")],
stderr=subprocess.STDOUT))
clientdata = fp.read()
except subprocess.CalledProcessError as e:

View File

@ -155,6 +155,8 @@ def main(args=sys.argv[1:]):
'interface on the provisioning net is attached')
parser.add_argument('--create-undercloud', action='store_true',
help='deploy the undercloud node.')
parser.add_argument('--ssh-key', default='',
help='ssh key for the ovb nodes to be deployed.')
parser.add_argument('--debug', '-d', action='store_true',
help='Set to debug mode.')
opts = parser.parse_args(args)
@ -175,6 +177,7 @@ def main(args=sys.argv[1:]):
"envsize":opts.envsize,
"ucinstance":opts.ucinstance,
"create_undercloud": "true" if opts.create_undercloud else "",
"ssh_key":opts.ssh_key,
}
job = gear.Job('lockenv', json.dumps(job_params))
client.submitJob(job)

View File

@ -85,6 +85,7 @@ export COMPUTE_HOSTS=
export SUBNODES_SSH_KEY=
export TEST_OVERCLOUD_DELETE=0
export OOOQ=0
export DEPLOY_OVB_EXTRA_NODE=0
if [[ $TOCI_JOBTYPE =~ scenario ]]; then
# note: we don't need PINGTEST_TEMPLATE here. See tripleo.sh. Though
@ -270,6 +271,12 @@ sudo yum install -y moreutils
# Ensure epel-release is not installed
sudo yum erase -y epel-release || :
if [ "$DEPLOY_OVB_EXTRA_NODE" = '1' ]; then
TEST_ENV_EXTRA_ARGS="--create-undercloud --ssh-key \"$(cat ~/.ssh/id_rsa.pub)\""
else
TEST_ENV_EXTRA_ARGS=""
fi
source $TRIPLEO_ROOT/tripleo-ci/scripts/metrics.bash
start_metric "tripleo.testenv.wait.seconds"
if [ -z "${TE_DATAFILE:-}" -a "$OSINFRA" = "0" ] ; then
@ -279,7 +286,9 @@ if [ -z "${TE_DATAFILE:-}" -a "$OSINFRA" = "0" ] ; then
# Kill the whole job if it doesn't get a testenv in 20 minutes as it likely will timout in zuul
( sleep 1200 ; [ ! -e /tmp/toci.started ] && sudo kill -9 $$ ) &
./testenv-client -b $GEARDSERVER:4730 -t $TIMEOUT_SECS --envsize $(($NODECOUNT+1)) --ucinstance $UCINSTANCEID -- $TOCIRUNNER
./testenv-client -b $GEARDSERVER:4730 -t $TIMEOUT_SECS \
--envsize $(($NODECOUNT+1)) --ucinstance $UCINSTANCEID \
$TEST_ENV_EXTRA_ARGS -- $TOCIRUNNER
else
$TOCIRUNNER
fi