Skip to content

Commit 0ca6ae1

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Perform manual error checks instead of set -e"
2 parents 6d9e9e8 + d82b8c6 commit 0ca6ae1

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ironic_python_agent/shell/copy_configdrive_to_disk.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
set -e
18-
1917
log() {
2018
echo "`basename $0`: $@"
2119
}
2220

21+
fail() {
22+
log "Error $@"
23+
exit 1
24+
}
25+
2326
usage() {
2427
[[ -z "$1" ]] || echo -e "USAGE ERROR: $@\n"
2528
echo "`basename $0`: CONFIGDRIVE DEVICE"
@@ -37,19 +40,20 @@ DEVICE="$2"
3740
# Check for preexisting partition for configdrive
3841
EXISTING_PARTITION=`/sbin/blkid -l -o device $DEVICE -t LABEL=config-2`
3942
if [[ $? == 0 ]]; then
43+
log "Existing configdrive found on ${DEVICE} at ${EXISTING_PARTITION}"
4044
ISO_PARTITION=$EXISTING_PARTITION
4145
else
4246
# Create small partition at the end of the device
4347
log "Adding configdrive partition to $DEVICE"
44-
parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
48+
parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0 || fail "creating configdrive on ${DEVICE}"
4549

4650
# Find partition we just created
4751
# Dump all partitions, ignore empty ones, then get the last partition ID
48-
ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'`
52+
ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'` || fail "finding ISO partition created on ${DEVICE}"
4953
fi
5054

5155
# This writes the ISO image to the config drive.
5256
log "Writing Configdrive contents in $CONFIGDRIVE to $ISO_PARTITION"
53-
dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct
57+
dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct || fail "writing Configdrive to ${ISO_PARTITION}"
5458

5559
log "${DEVICE} imaged successfully!"

0 commit comments

Comments
 (0)