summaryrefslogtreecommitdiff
path: root/ironic_python_agent/shell
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-06-16 09:27:45 +0000
committerGerrit Code Review <review@openstack.org>2014-06-16 09:27:45 +0000
commit0ca6ae10d51d319bc62e9a0ea258c7c5fc63885e (patch)
tree8ebecb8723e79a81ef200718d04124dab65311c4 /ironic_python_agent/shell
parent6d9e9e8ba739bfda944a0a004d4c3f78d9eea21f (diff)
parentd82b8c6bc0bf0131fb4bec6d18920191f68f2b54 (diff)
downloadironic-python-agent-0ca6ae10d51d319bc62e9a0ea258c7c5fc63885e.tar.gz
Merge "Perform manual error checks instead of set -e"
Diffstat (limited to 'ironic_python_agent/shell')
-rwxr-xr-xironic_python_agent/shell/copy_configdrive_to_disk.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/ironic_python_agent/shell/copy_configdrive_to_disk.sh b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
index da0b9097..8d6da02c 100755
--- a/ironic_python_agent/shell/copy_configdrive_to_disk.sh
+++ b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
@@ -14,12 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-set -e
-
log() {
echo "`basename $0`: $@"
}
+fail() {
+ log "Error $@"
+ exit 1
+}
+
usage() {
[[ -z "$1" ]] || echo -e "USAGE ERROR: $@\n"
echo "`basename $0`: CONFIGDRIVE DEVICE"
@@ -37,19 +40,20 @@ DEVICE="$2"
# Check for preexisting partition for configdrive
EXISTING_PARTITION=`/sbin/blkid -l -o device $DEVICE -t LABEL=config-2`
if [[ $? == 0 ]]; then
+ log "Existing configdrive found on ${DEVICE} at ${EXISTING_PARTITION}"
ISO_PARTITION=$EXISTING_PARTITION
else
# Create small partition at the end of the device
log "Adding configdrive partition to $DEVICE"
- parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
+ parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0 || fail "creating configdrive on ${DEVICE}"
# Find partition we just created
# Dump all partitions, ignore empty ones, then get the last partition ID
- ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'`
+ ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'` || fail "finding ISO partition created on ${DEVICE}"
fi
# This writes the ISO image to the config drive.
log "Writing Configdrive contents in $CONFIGDRIVE to $ISO_PARTITION"
-dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct
+dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct || fail "writing Configdrive to ${ISO_PARTITION}"
log "${DEVICE} imaged successfully!"