summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2012-09-11 10:25:49 -0500
committerGeorge Kraft <george.kraft@calxeda.com>2012-09-11 10:25:49 -0500
commit93ddbfb59cf1a14142e868e94c17eb92bb8e5c28 (patch)
tree0054cac85f8d6a84a53ba384e56ee13e4f86a614
parent75e4120664efa61f363771189244a742c224140b (diff)
downloadcxmanage-93ddbfb59cf1a14142e868e94c17eb92bb8e5c28.tar.gz
Add error tolerance to firmware downloads
This was done already for uploads, but we'll do it for downloads as well since they also occur during the firmware update process.
-rw-r--r--cxmanage/target.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/cxmanage/target.py b/cxmanage/target.py
index 05130e8..d9a3619 100644
--- a/cxmanage/target.py
+++ b/cxmanage/target.py
@@ -444,9 +444,11 @@ class Target:
while True:
try:
# Update the firmware
- handle = self.bmc.update_firmware(filename,
- partition_id, image.type, tftp_address).tftp_handle_id
- self._wait_for_transfer(handle)
+ result = self.bmc.update_firmware(filename,
+ partition_id, image.type, tftp_address)
+ if hasattr(result, "fw_error") and result.fw_error != None:
+ raise CxmanageError(result.fw_error)
+ self._wait_for_transfer(result.tftp_handle_id)
# Verify crc and activate
result = self.bmc.check_firmware(partition_id)
@@ -474,9 +476,21 @@ class Target:
basename = os.path.basename(filename)
partition_id = int(partition.partition)
image_type = partition.type.split()[1][1:-1]
- handle = self.bmc.retrieve_firmware(basename, partition_id,
- image_type, tftp_address).tftp_handle_id
- self._wait_for_transfer(handle)
+
+ errors = 0
+ while True:
+ try:
+ result = self.bmc.retrieve_firmware(basename, partition_id,
+ image_type, tftp_address)
+ if hasattr(result, "fw_error") and result.fw_error != None:
+ raise CxmanageError(result.fw_error)
+ self._wait_for_transfer(result.tftp_handle_id)
+ break
+ except CxmanageError as e:
+ errors += 1
+ if errors >= 3:
+ raise e
+
tftp.get_file(basename, filename)
return Image(filename, image_type)
@@ -506,7 +520,6 @@ class Target:
while result.status == "In progress":
if time.time() >= deadline:
- self.bmc.cancel_firmware(handle)
raise CxmanageError("Transfer timed out after 3 minutes")
time.sleep(1)