diff options
| author | Jay Faulkner <jay@jvf.cc> | 2014-06-04 10:24:50 -0700 |
|---|---|---|
| committer | Jay Faulkner <jay@jvf.cc> | 2014-06-10 08:22:31 -0700 |
| commit | d82b8c6bc0bf0131fb4bec6d18920191f68f2b54 (patch) | |
| tree | f97f0d53d239f525851adb37848fcc013a150bc9 /ironic_python_agent/shell | |
| parent | e6d9aafddb70e886975aedc09c3aa5d9209022b2 (diff) | |
| download | ironic-python-agent-d82b8c6bc0bf0131fb4bec6d18920191f68f2b54.tar.gz | |
Perform manual error checks instead of set -e
When using set -e, if you have a command fail, even when setting a
variable, it causes the node to fail. I have removed set -e and checked
error state where unexpected everywhere. I also added additional
logging.
Closes-Bug: #1326326
Change-Id: I7d2568c3693b9c486672e4322c7f01622aeba875
Diffstat (limited to 'ironic_python_agent/shell')
| -rwxr-xr-x | ironic_python_agent/shell/copy_configdrive_to_disk.sh | 14 |
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!" |
