2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 Red Hat, Inc. and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 # Ensure we fail the job if any steps fail.
13 set -x -o pipefail -o errexit
15 virtualenv "/tmp/v/openstack"
16 # shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091
17 source "/tmp/v/openstack/bin/activate"
18 pip install --upgrade --quiet "pip<10.0.0" setuptools
19 pip install --upgrade --quiet python-openstackclient
24 mkdir -p /tmp/apex_snapshots
25 pushd /tmp/apex_snapshots
27 wget artifacts.opnfv.org/apex/queens/noha/snapshot.properties
28 cat snapshot.properties
29 # shellcheck disable=SC1091
30 source snapshot.properties
31 SNAPSHOT_FILENAME=$(basename "$OPNFV_SNAP_URL")
33 wget --progress=dot:giga "$OPNFV_SNAP_URL"
34 gunzip -c "$SNAPSHOT_FILENAME" > snapshots.tar
36 # builder VMs don't have enough disk to handle a full un-tarring, so doing one
37 # big file at a time and deleting it from the tarball as a workaround for now
40 images=$(tar --list -f snapshots.tar | grep qcow2)
41 for image in $images; do
42 tar -xf snapshots.tar "$image"
43 tar --delete --file=snapshots.tar "$image"
46 # get the ssh keys and node.yaml for uploading to swift at the end
47 tar -xf snapshots.tar ./id_rsa
48 tar -xf snapshots.tar ./node.yaml
49 tar -xf snapshots.tar ./overcloudrc
53 # grab the right baremetal# for the controller(s) and compute(s)
54 CONTROLLER_NODE=$(grep -E 'type|vNode-name' node.yaml | grep -E -A1 controller | tail -n1 | awk '{print $2}')
55 COMPUTE_0_NODE=$(grep -E 'type|vNode-name' node.yaml | grep -E -A1 compute | tail -n1 | awk '{print $2}')
56 COMPUTE_1_NODE=$(grep -E 'type|vNode-name' node.yaml | grep -E -A1 compute | head -n2 | tail -n1 | awk '{print $2}')
58 # Customize images to work in ODL Vexxhost infra
59 sudo yum install -y libguestfs-tools
60 export LIBGUESTFS_BACKEND=direct
61 virt-customize -a "$CONTROLLER_NODE.qcow2" \
62 --run-command "crudini --set /var/lib/config-data/puppet-generated/neutron/etc/neutron/plugins/ml2/ml2_conf.ini ml2 physical_network_mtus datacentre:1458" \
63 --run-command "crudini --set /var/lib/config-data/puppet-generated/neutron/etc/neutron/plugins/ml2/ml2_conf.ini ml2 path_mtu 1458" \
64 --run-command "crudini --set /var/lib/config-data/puppet-generated/neutron/etc/neutron/neutron.conf '' global_physnet_mtu 1458" \
65 --run-command "crudini --set /var/lib/config-data/puppet-generated/neutron/etc/neutron/dhcp_agent.ini '' debug true" \
67 virt-customize -a "$COMPUTE_0_NODE.qcow2" \
68 --run-command "crudini --set /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf libvirt virt_type qemu"
70 virt-customize -a "$COMPUTE_1_NODE.qcow2" \
71 --run-command "crudini --set /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova/nova.conf libvirt virt_type qemu"
73 for image in $CONTROLLER_NODE $COMPUTE_0_NODE $COMPUTE_1_NODE
75 # Change interface MTU to account for default network mtu of 1458
76 virt-customize -a "$image.qcow2" \
77 --run-command 'sudo echo "MTU=\"1458\"" >> /etc/sysconfig/network-scripts/ifcfg-eth0' \
78 --run-command 'sudo echo "MTU=\"1458\"" >> /etc/sysconfig/network-scripts/ifcfg-br-int' \
79 --run-command 'sudo echo "MTU=\"1458\"" >> /etc/sysconfig/network-scripts/ifcfg-ovs-system' \
80 --run-command "sudo crudini --set /etc/selinux/config '' SELINUX permissive"
87 # clean out any zombie OPNFV - apex images that *may* be left over from troubled jobs
88 openstack image list | grep -E 'OPNFV - apex.*new ' | awk '{print "openstack image delete",$2}' | sh || true
90 qemu-img convert -f qcow2 -O raw "/tmp/apex_snapshots/$CONTROLLER_NODE.qcow2" "/tmp/apex_snapshots/$CONTROLLER_NODE.raw"
91 rm "/tmp/apex_snapshots/$CONTROLLER_NODE.qcow2"
92 qemu-img convert -f qcow2 -O raw "/tmp/apex_snapshots/$COMPUTE_0_NODE.qcow2" "/tmp/apex_snapshots/$COMPUTE_0_NODE.raw"
93 rm "/tmp/apex_snapshots/$COMPUTE_0_NODE.qcow2"
94 qemu-img convert -f qcow2 -O raw "/tmp/apex_snapshots/$COMPUTE_1_NODE.qcow2" "/tmp/apex_snapshots/$COMPUTE_1_NODE.raw"
95 rm "/tmp/apex_snapshots/$COMPUTE_1_NODE.qcow2"
97 # create .new images first, then we can delete the existing and rename .new
98 # to existing to reduce the delta of when these images might be unavailable
99 CONTROLLER_IMAGE_NAME="ZZCI - OPNFV - apex - controller - 0"
100 COMPUTE_0_IMAGE_NAME="ZZCI - OPNFV - apex - compute - 0"
101 COMPUTE_1_IMAGE_NAME="ZZCI - OPNFV - apex - compute - 1"
103 openstack image create \
104 --disk-format raw --container-format bare \
105 --file "/tmp/apex_snapshots/$CONTROLLER_NODE.raw" "$CONTROLLER_IMAGE_NAME.new"
106 openstack image create \
107 --disk-format raw --container-format bare \
108 --file "/tmp/apex_snapshots/$COMPUTE_0_NODE.raw" "$COMPUTE_0_IMAGE_NAME.new"
109 openstack image create \
110 --disk-format raw --container-format bare \
111 --file "/tmp/apex_snapshots/$COMPUTE_1_NODE.raw" "$COMPUTE_1_IMAGE_NAME.new"
113 # clean out any non ".new" OPNFV - apex images. In the case of a previously failed
114 # or aborted apex management job, we can end up with multiple images with the same
115 # name so being thorough here.
116 openstack image list | grep -E 'OPNFV - apex' | grep -Ev 'new' | awk '{print "openstack image delete",$2}' | sh
118 openstack image set --name "$CONTROLLER_IMAGE_NAME" "$CONTROLLER_IMAGE_NAME.new"
119 openstack image set --tag "Date Uploaded: $(date)" "$CONTROLLER_IMAGE_NAME"
120 openstack image set --tag "Apex Archive: $(basename "$OPNFV_SNAP_URL")" "$CONTROLLER_IMAGE_NAME"
122 openstack image set --name "$COMPUTE_0_IMAGE_NAME" "$COMPUTE_0_IMAGE_NAME.new"
123 openstack image set --tag "Date Uploaded: $(date)" "$COMPUTE_0_IMAGE_NAME"
124 openstack image set --tag "Apex Archive: $(basename "$OPNFV_SNAP_URL")" "$COMPUTE_0_IMAGE_NAME"
126 openstack image set --name "$COMPUTE_1_IMAGE_NAME" "$COMPUTE_1_IMAGE_NAME.new"
127 openstack image set --tag "Date Uploaded: $(date)" "$COMPUTE_1_IMAGE_NAME"
128 openstack image set --tag "Apex Archive: $(basename "$OPNFV_SNAP_URL")" "$COMPUTE_1_IMAGE_NAME"
130 # Now that the images should be up, active and ready, we can update
131 # the ssh key and node.yaml in swift
132 openstack container create OPNFV-APEX-SNAPSHOTS
133 openstack object create OPNFV-APEX-SNAPSHOTS /tmp/apex_snapshots/node.yaml --name node.yaml
134 openstack object create OPNFV-APEX-SNAPSHOTS /tmp/apex_snapshots/id_rsa --name id_rsa
135 openstack object create OPNFV-APEX-SNAPSHOTS /tmp/apex_snapshots/overcloudrc --name overcloudrc
136 openstack object list OPNFV-APEX-SNAPSHOTS