summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2013-07-22 16:14:54 -0500
committerGeorge Kraft <george.kraft@calxeda.com>2013-07-22 16:14:54 -0500
commit9ad84db4aae678ce99bd27498802b563bd7071cf (patch)
tree36f5d4c82a12ee0b73622e26419b2421423aed2d
parentc5ff40e373f98e544f054ac2253ef04ef2d967e0 (diff)
downloadcxmanage-9ad84db4aae678ce99bd27498802b563bd7071cf.tar.gz
node: Remove try/catch of Exception around the UbootEnv class
It's squashing another error that prevents ubootenv updates from working -- boot order and pxe config aren't preserved as they should be. To fix this, replace UnknownBootCmdError with UbootenvError. Just something more general to say "we can't recognize the environment". UbootEnv can raise that instead of Exception.
-rw-r--r--cxmanage_api/cx_exceptions.py19
-rw-r--r--cxmanage_api/node.py5
-rw-r--r--cxmanage_api/ubootenv.py16
3 files changed, 20 insertions, 20 deletions
diff --git a/cxmanage_api/cx_exceptions.py b/cxmanage_api/cx_exceptions.py
index b74a927..f390392 100644
--- a/cxmanage_api/cx_exceptions.py
+++ b/cxmanage_api/cx_exceptions.py
@@ -259,26 +259,25 @@ class InvalidImageError(Exception):
return self.msg
-class UnknownBootCmdError(Exception):
- """Raised when the boot command is not: run bootcmd_pxe, run bootcmd_sata,
- run bootcmd_mmc, setenv bootdevice, or reset.
+class UbootenvError(Exception):
+ """Raised when the UbootEnv class fails to interpret the ubootenv
+ environment variables.
- >>> from cxmanage_api.cx_exceptions import UnknownBootCmdError
- >>> raise UnknownBootCmdError('My custom exception text!')
+ >>> from cxmanage_api.cx_exceptions import UbootenvError
+ >>> raise UbootenvError('My custom exception text!')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
- cxmanage_api.cx_exceptions.UnknownBootCmdError: My custom exception text!
+ cxmanage_api.cx_exceptions.UbootenvError: My custom exception text!
:param msg: Exceptions message and details to return to the user.
:type msg: string
- :raised: When the boot command is not: run bootcmd_pxe, run bootcmd_sata,
- run bootcmd_mmc, setenv bootdevice, or reset.
+ :raised: When ubootenv settings are unrecognizable.
"""
def __init__(self, msg):
- """Default constructor for the UnknownBootCmdError class."""
- super(UnknownBootCmdError, self).__init__()
+ """Default constructor for the UbootenvError class."""
+ super(UbootenvError, self).__init__()
self.msg = msg
def __str__(self):
diff --git a/cxmanage_api/node.py b/cxmanage_api/node.py
index be89335..9ae847f 100644
--- a/cxmanage_api/node.py
+++ b/cxmanage_api/node.py
@@ -49,7 +49,8 @@ from cxmanage_api.ubootenv import UbootEnv as UBOOTENV
from cxmanage_api.ip_retriever import IPRetriever as IPRETRIEVER
from cxmanage_api.cx_exceptions import TimeoutError, NoSensorError, \
SocmanVersionError, FirmwareConfigError, PriorityIncrementError, \
- NoPartitionError, TransferFailure, ImageSizeError, PartitionInUseError
+ NoPartitionError, TransferFailure, ImageSizeError, \
+ PartitionInUseError, UbootenvError
class Node(object):
@@ -739,7 +740,7 @@ class Node(object):
"Done uploading ubootenv image to first " + \
"partition ('running partition')"
)
- except (ValueError, Exception):
+ except (ValueError, UbootenvError):
self._upload_image(image, running_part, priority)
updated_partitions += [running_part, factory_part]
diff --git a/cxmanage_api/ubootenv.py b/cxmanage_api/ubootenv.py
index 12d550d..cd1a35a 100644
--- a/cxmanage_api/ubootenv.py
+++ b/cxmanage_api/ubootenv.py
@@ -33,7 +33,7 @@ import struct
from cxmanage_api.simg import has_simg, get_simg_contents
from cxmanage_api.crc32 import get_crc32
-from cxmanage_api.cx_exceptions import UnknownBootCmdError
+from cxmanage_api.cx_exceptions import UbootenvError
ENVIRONMENT_SIZE = 8192
@@ -87,7 +87,7 @@ class UbootEnv:
:raises ValueError: If an invalid boot device is specified.
:raises ValueError: If 'retry' and 'reset' args are used together.
- :raises Exception: If the u-boot environment is unrecognized
+ :raises UbootenvError: If the u-boot environment is unrecognized
"""
validate_boot_args(boot_args)
@@ -103,7 +103,7 @@ class UbootEnv:
elif all(x in self.variables for x in UBOOTENV_V2_VARIABLES):
version = 2
else:
- raise Exception("Unrecognized u-boot environment")
+ raise UbootenvError("Unrecognized u-boot environment")
for arg in boot_args:
if arg == "retry":
@@ -159,7 +159,7 @@ class UbootEnv:
:returns: Boot order for this U-Boot Environment.
:rtype: string
- :raises UnknownBootCmdError: If a boot command is unrecognized.
+ :raises UbootenvError: If a boot command is unrecognized.
"""
boot_args = []
@@ -171,7 +171,7 @@ class UbootEnv:
elif target == "scsi":
boot_args.append("disk")
else:
- raise UnknownBootCmdError("Unrecognized boot target: %s"
+ raise UbootenvError("Unrecognized boot target: %s"
% target)
else:
if "bootcmd_default" in self.variables:
@@ -198,7 +198,7 @@ class UbootEnv:
boot_args.append("reset")
break
else:
- raise UnknownBootCmdError("Unrecognized boot command: %s"
+ raise UbootenvError("Unrecognized boot command: %s"
% command)
if retry:
@@ -249,7 +249,7 @@ class UbootEnv:
:returns: Boot order for this U-Boot Environment.
:rtype: string
- :raises Exception: If the u-boot environment value is not recognized.
+ :raises ValueError: If the u-boot environment value is not recognized.
"""
@@ -264,7 +264,7 @@ class UbootEnv:
elif (xgmac == "xgmac1"):
return "eth1"
else:
- raise Exception("Unrecognized value for ethprime")
+ raise ValueError("Unrecognized value for ethprime")
else:
return "eth0"