puppet-tripleo fork integration 83/15483/4
authorDan Radez <dradez@redhat.com>
Mon, 13 Jun 2016 18:56:16 +0000 (14:56 -0400)
committerDan Radez <dradez@redhat.com>
Tue, 14 Jun 2016 00:29:19 +0000 (20:29 -0400)
moving the github integration with pull requests
into a function so we can continue to service opnfv-tht
and also service opnfv-puppet-tripleo with the same code

opnfv-puppet-tripleo-pr: 3

Change-Id: Ief2b1e7309defce9ed2029f6baade3c1371b7d96
Signed-off-by: Dan Radez <dradez@redhat.com>
build/cache.sh
build/functions.sh [new file with mode: 0644]
build/overcloud-full.sh
build/undercloud.sh

index a88ffce..123748a 100644 (file)
@@ -24,6 +24,10 @@ function cache_git_tar {
 # $1 = download url
 # $2 = filename to write to
 function curl_file {
+    if [ -f $CACHE_DIR/$2 ]; then
+    echo "Removing stale $2"
+        rm -f $CACHE_DIR/$2
+    fi
     echo "Downloading $1"
     echo "Cache download location: $CACHE_DIR/$2"
     until curl -C- -L -o $CACHE_DIR/$2 $1  || (( count++ >= 20 )); do
diff --git a/build/functions.sh b/build/functions.sh
new file mode 100644 (file)
index 0000000..e61102e
--- /dev/null
@@ -0,0 +1,46 @@
+##############################################################################
+# Copyright (c) 2016 Dan Radez (Red Hat) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+clone_fork () {
+    # ARG 1: opnfv-tht or opnfv-python-triplo
+    echo "Cloning $1"
+
+    # Use apex tripleo-heat-templates fork
+    local ghcreds=""
+    local pr_num=""
+    local ref="stable/colorado"
+    local repo="https://github.com/trozet/$1"
+
+    if git log -1 | grep "${1}-pr:" | grep -o '[0-9]*'; then
+      pr_num=$(git log -1 | grep "${1}-pr:" | grep -o '[0-9]*')
+    fi
+
+    if [ "$pr_num" != "" ]; then
+      echo "Using pull request $pr_num from $repo"
+      # Source credentials since we are rate limited to 60/day
+      if [ -f ~/.githubcreds ]; then
+        source ~/.githubcreds
+        ghcreds=" -u $GHUSERNAME:$GHACCESSTOKEN"
+      fi
+
+      PR=$(curl $ghcreds https://api.github.com/repos/trozet/$1/pulls/$pr_num)
+
+      # Do not pull from merged branches
+      MERGED=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['merged']")
+      if [ "$MERGED" == "False" ]; then
+        ref=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['ref']")
+        echo "Setting GitHub Ref to: $REF"
+        repo=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['repo']['clone_url']")
+        echo "Setting GitHub URL to: $repo"
+      fi
+    fi
+
+    rm -rf $1
+    git clone $repo -b $ref $1
+}
index af978ed..fe67c28 100755 (executable)
@@ -10,6 +10,7 @@
 set -e
 source ./cache.sh
 source ./variables.sh
+source ./functions.sh
 
 populate_cache "$rdo_images_uri/overcloud-full.tar"
 
@@ -21,6 +22,12 @@ mv -f images/overcloud-full.qcow2 images/overcloud-full_build.qcow2
 #####  Prep initial overcloud image with common deps #####
 ##########################################################
 
+# prep opnfv-puppet-tripleo for undercloud
+clone_fork opnfv-puppet-tripleo
+pushd opnfv-puppet-tripleo > /dev/null
+git archive --format=tar.gz --prefix=tripleo/ HEAD > ../opnfv-puppet-tripleo.tar.gz
+popd > /dev/null
+
 pushd images > /dev/null
 
 dpdk_pkg_str=''
@@ -29,10 +36,12 @@ for package in ${dpdk_rpms[@]}; do
   dpdk_pkg_str+=" --upload $package:/root/dpdk_rpms"
 done
 
-# remove openstack-neutron-openvswitch, ain't nobody need that in OPNFV
+# installing forked opnfv-puppet-tripleo
 # enable connection tracking for protocal sctp
 # upload dpdk rpms but do not install
 LIBGUESTFS_BACKEND=direct virt-customize \
+    --upload ../opnfv-puppet-tripleo.tar.gz:/etc/puppet/modules \
+    --run-command "cd /etc/puppet/modules && rm -rf tripleo && tar xzf opnfv-puppet-tripleo.tar.gz" \
     --run-command "echo 'nf_conntrack_proto_sctp' > /etc/modules-load.d/nf_conntrack_proto_sctp.conf" \
     --run-command "mkdir /root/dpdk_rpms" \
     $dpdk_pkg_str \
index 551dbd8..c1d7c3a 100755 (executable)
 set -e
 source ./cache.sh
 source ./variables.sh
+source ./functions.sh
 
 populate_cache "$rdo_images_uri/undercloud.qcow2"
 if [ ! -d images ]; then mkdir images/; fi
 cp -f cache/undercloud.qcow2 images/undercloud_build.qcow2
 
-#Adding OpenStack packages to undercloud
-pushd images > /dev/null
-
-# Use apex tripleo-heat-templates fork
-PR_NUMBER=""
-REF="stable/colorado"
-REPO="https://github.com/trozet/opnfv-tht"
-
-if git log -1 | grep 'opnfv-tht-pr:' | grep -o '[0-9]*'; then
-  PR_NUMBER=$(git log -1 | grep 'opnfv-tht-pr:' | grep -o '[0-9]*')
-fi
-
-if [ "$PR_NUMBER" != "" ]; then
-  echo "Using pull request $PR_NUMBER from $REPO"
-  # Source credentials since we are rate limited to 60/day
-  GHCREDS=""
-  if [ -f ~/.githubcreds ]; then
-    source ~/.githubcreds
-    GHCREDS=" -u $GHUSERNAME:$GHACCESSTOKEN"
-  fi
-
-  PR=$(curl $GHCREDS https://api.github.com/repos/trozet/opnfv-tht/pulls/$PR_NUMBER)
-
-  # Do not pull from merged branches
-  MERGED=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['merged']")
-  if [ "$MERGED" == "False" ]; then
-    REF=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['ref']")
-    echo "Setting GitHub Ref to: $REF"
-    REPO=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['repo']['clone_url']")
-    echo "Setting GitHub URL to: $REPO"
-  fi
-fi
-
-rm -rf opnfv-tht
-git clone $REPO -b $REF opnfv-tht
-
+# prep opnfv-tht for undercloud
+clone_fork opnfv-tht
 pushd opnfv-tht > /dev/null
 git archive --format=tar.gz --prefix=openstack-tripleo-heat-templates/ HEAD > ../opnfv-tht.tar.gz
 popd > /dev/null
-LIBGUESTFS_BACKEND=direct virt-customize --upload opnfv-tht.tar.gz:/usr/share \
-                                         --run-command "cd /usr/share && rm -rf openstack-tripleo-heat-templates && tar xzf opnfv-tht.tar.gz" \
-                                         -a undercloud_build.qcow2
 
-# install the packages above and enabling ceph to live on the controller
+pushd images > /dev/null
+# installing forked opnfv-tht
+# enabling ceph OSDs to live on the controller
 # OpenWSMan package update supports the AMT Ironic driver for the TealBox
+# seeding configuration files specific to OPNFV
 LIBGUESTFS_BACKEND=direct virt-customize \
+    --upload ../opnfv-tht.tar.gz:/usr/share \
+    --run-command "cd /usr/share && rm -rf openstack-tripleo-heat-templates && tar xzf opnfv-tht.tar.gz" \
     --run-command "sed -i '/ControllerEnableCephStorage/c\\  ControllerEnableCephStorage: true' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" \
     --run-command "sed -i '/ComputeEnableCephStorage/c\\  ComputeEnableCephStorage: true' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" \
     --run-command "curl http://download.opensuse.org/repositories/Openwsman/CentOS_CentOS-7/Openwsman.repo > /etc/yum.repos.d/wsman.repo" \