summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2012-08-16 12:16:09 -0500
committerGeorge Kraft <george.kraft@calxeda.com>2012-08-16 12:16:09 -0500
commit6d951921d5176bac37922bcd68a3f38a1a72d8dd (patch)
tree9ee559d06e28eaf00985b3e9d2c47200fb2409df
parentceeb912f50c9acaee69ce36ee137ea871798d6d3 (diff)
downloadcxmanage-6d951921d5176bac37922bcd68a3f38a1a72d8dd.tar.gz
target: Use fwinfo "partition" response field instead of "slot"
Also update controller_test and target_test with these changes.
-rw-r--r--cxmanage/target.py19
-rw-r--r--cxmanage_test/controller_test.py4
-rw-r--r--cxmanage_test/target_test.py10
3 files changed, 17 insertions, 16 deletions
diff --git a/cxmanage/target.py b/cxmanage/target.py
index a08d7c9..b69c7c9 100644
--- a/cxmanage/target.py
+++ b/cxmanage/target.py
@@ -218,20 +218,20 @@ class Target:
""" Get firmware info from the target """
try:
fwinfo = [x for x in self.bmc.get_firmware_info()
- if hasattr(x, "slot")]
+ if hasattr(x, "partition")]
if len(fwinfo) == 0:
raise CxmanageError("Failed to retrieve firmware info")
# Flag CDB as "in use" based on socman info
for a in range(1, len(fwinfo)):
previous = fwinfo[a-1]
- partition = fwinfo[a]
- if (partition.type.split()[1][1:-1] == "CDB" and
- partition.in_use == "Unknown"):
+ current = fwinfo[a]
+ if (current.type.split()[1][1:-1] == "CDB" and
+ current.in_use == "Unknown"):
if previous.type.split()[1][1:-1] != "SOC_ELF":
- partition.in_use = "1"
+ current.in_use = "1"
else:
- partition.in_use = previous.in_use
+ current.in_use = previous.in_use
return fwinfo
@@ -423,6 +423,7 @@ class Target:
tftp_address = "%s:%s" % (tftp.get_address(self.address),
tftp.get_port())
+ partition_id = int(partition.partition)
if version == None:
version = int(partition.version, 16)
daddr = int(partition.daddr, 16)
@@ -430,13 +431,12 @@ class Target:
# Check image size
if image.size() > int(partition.size, 16):
raise CxmanageError("%s image is too large for partition %i" %
- image.type, int(partition.slot))
+ image.type, partition_id)
# Upload image to tftp server
filename = image.upload(self.work_dir, tftp, version, daddr)
# Send firmware update command
- partition_id = int(partition.slot)
image_type = image.type
result = self.bmc.update_firmware(filename,
partition_id, image_type, tftp_address)
@@ -463,8 +463,9 @@ class Target:
# Download the image
filename = tempfile.mkstemp(prefix="%s/img_" % self.work_dir)[1]
basename = os.path.basename(filename)
+ partition_id = int(partition.partition)
image_type = partition.type.split()[1][1:-1]
- handle = self.bmc.retrieve_firmware(basename, int(partition.slot),
+ handle = self.bmc.retrieve_firmware(basename, partition_id,
image_type, tftp_address).tftp_handle_id
self._wait_for_transfer(handle)
tftp.get_file(basename, filename)
diff --git a/cxmanage_test/controller_test.py b/cxmanage_test/controller_test.py
index bc9937e..7420100 100644
--- a/cxmanage_test/controller_test.py
+++ b/cxmanage_test/controller_test.py
@@ -306,7 +306,7 @@ class DummyTarget:
self.executed.append(("update_firmware", images))
time.sleep(random.randint(0, 2))
- def get_sensors(self):
+ def get_sensors(self, name=""):
self.executed.append("get_sensors")
power_value = "%f (+/- 0) Watts" % random.uniform(0, 10)
temp_value = "%f (+/- 0) degrees C" % random.uniform(30, 50)
@@ -314,7 +314,7 @@ class DummyTarget:
TestSensor("Node Power", power_value),
TestSensor("Board Temp", temp_value)
]
- return sensors
+ return [x for x in sensors if name.lower() in x.sensor_name.lower()]
def config_reset(self, tftp):
self.executed.append("config_reset")
diff --git a/cxmanage_test/target_test.py b/cxmanage_test/target_test.py
index 7c1b0b2..30f32c6 100644
--- a/cxmanage_test/target_test.py
+++ b/cxmanage_test/target_test.py
@@ -388,26 +388,26 @@ class DummyBMC(LanBMC):
return Result()
class Partition:
- def __init__(self, slot, slot_type, offset=0,
+ def __init__(self, partition, type, offset=0,
size=0, version=0, daddr=0, in_use=None):
self.updates = 0
self.retrieves = 0
self.checks = 0
self.activates = 0
- self.fwinfo = FWInfoEntry(slot, slot_type, offset,
+ self.fwinfo = FWInfoEntry(partition, type, offset,
size, version, daddr, in_use)
class FWInfoEntry:
""" Firmware info for a single partition """
- def __init__(self, slot, slot_type, offset=0,
+ def __init__(self, partition, type, offset=0,
size=0, version=0, daddr=0, in_use=None):
- self.slot = "%2i" % slot
+ self.partition = "%2i" % partition
self.type = {
2: "02 (S2_ELF)",
3: "03 (SOC_ELF)",
10: "0a (CDB)",
11: "0b (UBOOTENV)"
- }[slot_type]
+ }[type]
self.offset = "%8x" % offset
self.size = "%8x" % size
self.version = "%8x" % version