~ubuntu-on-ec2/vmbuilder/jenkins_kvm-kvp-telemetry-xenial

« back to all changes in this revision

Viewing changes to jenkins/CloudImages_Vagrant.sh

  • Committer: Ben Howard
  • Date: 2013-01-17 17:52:07 UTC
  • Revision ID: ben.howard@canonical.com-20130117175207-p01v7qn1c00wybxt
Major revision to build process:
- Added tests/decider.py for evaluating failures in legacy EC2 tests
    for promotion
- Vagrant images:
  - moved to /srv/ec2-images/vagrant
  - added logic for removal of old images
  - renamed images to ${suite}-server-cloudimg-${arch}-vagrant-disk1.img
  - added message about supportability of images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
rm {failed,success} || /bin/true
14
14
 
15
15
# Copy the target disk image
16
 
disk_orig="${SUITE}-server-cloudimg-${ARCH_TYPE:-$ARCH}-disk1.img"
17
 
disk_cp="${disk_orig//cloudimg/cloudimg-vagrant}"
 
16
ARCH_TYPE=${ARCH_TYPE:-$ARCH}
 
17
disk_orig="${SUITE}-server-cloudimg-${ARCH_TYPE}-disk1.img"
 
18
disk_cp="${disk_orig//$ARCH_TYPE/$ARCH_TYPE-vagrant}"
18
19
disk_root="/srv/ec2-images/${SUITE}/${SERIAL:-current}"
19
20
disk_working="${WORKSPACE}/${disk_cp}"
20
21
final_disk="${WORKSPACE}/box-disk1.vdi"
 
22
final_location="/srv/ec2-images/vagrant/${SUITE}/${SERIAL}"
21
23
box_name="${disk_working//.img/.box}"
22
24
raw_f="${WORKSPACE}/raw_f-$(date +%s).img"
23
25
 
26
28
 
27
29
# Launch KVM to do the work
28
30
${kvm}/launch_kvm.sh \
29
 
        --id "${ARCH_TYPE:-$ARCH}-${BUILD_ID}" \
 
31
        --id "${ARCH_TYPE}-${BUILD_ID}" \
30
32
        --user-data "${kvm}/cloud-vps.cfg" \
31
33
        --cloud-config "${kvm}/img-vagrant.tmpl" \
32
34
        --extra-disk "${disk_working}" \
44
46
    ${disk_working//.img/.raw} ${final_disk}
45
47
 
46
48
# Create the VM
47
 
vmname="ubuntu-cloudimg-${SUITE}-vagrant-${ARCH_TYPE:-$ARCH}"
 
49
vmname="ubuntu-cloudimg-${SUITE}-vagrant-${ARCH_TYPE}"
48
50
vboxmanage modifyhd --compact ${final_disk}
49
51
 
50
52
vboxmanage createvm \
114
116
rm "${raw_f}" || /bin/true
115
117
 
116
118
# Put the box in place
117
 
cp ${box_name} ${disk_root} ||
 
119
mkdir -p "${final_location}" ||
 
120
    fail "Unable to create the vagrant image location"
 
121
 
 
122
cp ${box_name} ${final_location} ||
118
123
    fail "Failed to place vagrant image in final home"
 
124
 
 
125
# Cleanup old builds
 
126
builds=($(find /srv/ec2-images/vagrant/${SUITE} -mindepth 1 -maxdepth 1 -type d | sort -r))
 
127
build_count="${#builds[@]}"
 
128
 
 
129
echo "------------------------"
 
130
echo "Clean-up for prior builds"
 
131
echo "Found ${build_count} builds for consideration"
 
132
 
 
133
for b in ${builds[@]}
 
134
do
 
135
    echo " - found build ${b}"
 
136
done
 
137
echo ""
 
138
 
 
139
[ "${build_count}" -gt 4 ] && {
 
140
    for item in $(seq 4 ${build_count})
 
141
    do
 
142
        [ -e "${builds[$item]}" ] && {
 
143
            echo "Removing build ${builds[$item]} for deletion"
 
144
            rm -rf ${builds[$item]} ||
 
145
                echo "Failed to remove build ${builds[$item]}"
 
146
        }
 
147
    done
 
148
 
 
149
    for item in $(seq 0 3)
 
150
    do
 
151
        [ -e "${builds[$item]}" ] &&
 
152
            echo "Preserving build ${builds[$item]}"
 
153
    done
 
154
 
 
155
} || echo "No builds marked for removal"
 
156