3 # Copyright (c) 2019 Red Hat
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 set -e -u -x -o pipefail
19 export PATH=$PATH:/usr/local/go/bin:/usr/local/bin
20 KNI_PATH='src/gerrit.akraino.org/kni/'
21 SITE_NAME='testing.virt.edge-sites.net'
23 echo '---> Starting kni installer generation'
24 export GOPATH=${WORKSPACE}/
26 # first build kni installer
27 sudo rm -rf ${WORKSPACE}/${KNI_PATH}
28 mkdir -p ${WORKSPACE}/${KNI_PATH}/installer
29 cp -a installer ${WORKSPACE}/${KNI_PATH}/
30 pushd ${WORKSPACE}/${KNI_PATH}/installer
31 make build 2>&1 | tee ${WORKSPACE}/build.log
33 # do a host preparation and cleanup
34 bash utils/prep_host.sh virt.edge-sites.net
35 wget https://raw.githubusercontent.com/openshift/installer/master/scripts/maintenance/virsh-cleanup.sh
36 chmod a+x ./virsh-cleanup.sh
37 sudo -E bash -c "yes Y | ./virsh-cleanup.sh"
39 # add the right credentials to kni
40 mkdir $HOME/.kni || true
41 cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
42 cp $HOME/.ssh/id_rsa.pub $HOME/.kni/id_rsa.pub || true
45 sudo rm -rf /$HOME/.kni/${SITE_NAME}/final_manifests || true
46 ./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_requirements.log
47 ./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_manifests.log
50 source $HOME/.kni/${SITE_NAME}/profile.env
53 sudo -E $HOME/.kni/${SITE_NAME}/requirements/openshift-install create cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/libvirt_deploy.log
55 kill $FUNCTION_PID || true
58 echo "metadata.json for removing cluster"
59 cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
61 if [ $STATUS -ne 0 ]; then
62 echo "Error deploying in libvirt"
66 echo "Cluster successfully deployed! Start applying workloads"
67 ./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_workloads.log
70 if [ $STATUS -ne 0 ]; then
71 echo "Error applying workloads to libvirt"