Improve respin scripts 25/1825/11
authorC.J. Collier <cjcollier@linuxfoundation.org>
Thu, 30 Jun 2016 13:56:43 +0000 (06:56 -0700)
committerC.J. Collier <cjcollier@linuxfoundation.org>
Tue, 12 Jul 2016 21:25:30 +0000 (21:25 +0000)
commitafa1309db5813b191f5852bcab05f1f0c1d38047
tree2ffc61d7e64203cc54bb5b6f7bdae35439c8490c
parentc8466ee183e872cdb3ee9f49dd3eccdaa5e87b5c
Improve respin scripts

In order to create a new OpenStack basebuild Images, a multi-phase
process must be executed.

The first phase is to configure the system for use with dynamic
language environments.

Due to security precautions, We do not currently have the ability to
automate the process of respinning a new Image.  We have a goal of
fully automating the process so that a new Image will be generated on
every commit.  Until the process is self-hosted, we must manually
fetch credentials from the OpenStack provider's web UI in order to
make use of the python openstack bindings and to complete the
basebuild re-spin process using Vagrant.

The more generic portions of the Image are imported once every two to
three weeks from upstream distributors.  This duration is computed
thus:

  $(perl -I${CI_MGMT}/vagrant/lib -MRespin -e 'Respin::latest_src_age( "${NOW_TS}", "${SRC_TS}" )') | jq .week

Once fetched, these qcow2 Images are pushed to OpenStack using glance
and labelled as:

  "$(lsb_release -i) $(lsb_release -r) (YYYYMMDDTHHMMSS) - LF upload"

The generated basebuild Images are pushed to OpenStack with glance
labelled as:

  "$(lsb_release -i) $(lsb_release -r) - basebuild - YYYYMMDDTHHMMSS"

====

This patch makes it possible to perform the above multi-phase
processes by executing a single script:

  bash scripts/respin-jcloud-images.sh

This script sources a function library from the following file:

  vagrant/lib/respin-functions.sh

Defined in this library are (among others):

  # Fetch latest image from upstream distributor
  download_deb_image( $dist, $version, $arch )
  download_rh_image( $dist, $version, $arch )

  # Fetch latest image from upstream distributor
  create_deb_image( $dist, $version, $arch )
  create_rh_image( $dist, $version, $arch )

  # Run Vagrant provisioning on upstream image
  respin_deb_image( $dist, $version, $arch )
  respin_rh_image( $dist, $version, $arch )

The following script initializes vagrant and the following dynamic language environments:

  * python-virtualenv
  * pip
  * setuptools
  * python-{cinder,glance,keystone,neutron,nova,openstack}client

  * rbenv
  * Vagrant
  * vagrant-openstack-provider

  * nodejs
  * jq

  * local::lib
  * JSON::XS
  * DateTime
  * DateTime::Format::Duration
  * DateTime::Duration

  scripts/init-respin-env.sh

The following module compares ISO 8601 dates (as included in Image labels) with
the current time and prints to STDOUT the count of weeks, days, hours,
minutes and seconds in JSON:

  vagrant/lib/Respin.pm

Change-Id: I434cf2882e5e337ae4b55a4a7acb774a62b528b7
Signed-off-by: C.J. Collier <cjcollier@linuxfoundation.org>
scripts/init-respin-env.sh [new file with mode: 0644]
scripts/respin-jcloud-images.sh
scripts/setup-vagrant.sh [deleted file]
vagrant/lib/Respin.pm [new file with mode: 0644]
vagrant/lib/respin-functions.sh