1212####################################################################################
1313
1414from frugy import __version__
15- from frugy .areas import CommonHeader , ChassisInfo , BoardInfo , ProductInfo
15+ from frugy .areas import CommonHeader , ChassisInfo , BoardInfo , ProductInfo , InternalUse
1616from frugy .multirecords import MultirecordArea
1717import frugy .multirecords_ipmi
1818import frugy .multirecords_picmg
@@ -46,6 +46,7 @@ def import_log(msg):
4646
4747class Fru :
4848 _area_table_lookup = bidict ({
49+ 'InternalUse' : 'internal_use_offs' ,
4950 'ChassisInfo' : 'chassis_info_offs' ,
5051 'BoardInfo' : 'board_info_offs' ,
5152 'ProductInfo' : 'product_info_offs' ,
@@ -61,6 +62,7 @@ def __init__(self, initdict=None):
6162
6263 def factory (self , cls_name , cls_args = None ):
6364 map = {
65+ 'InternalUse' : InternalUse ,
6466 'ChassisInfo' : ChassisInfo ,
6567 'BoardInfo' : BoardInfo ,
6668 'ProductInfo' : ProductInfo ,
@@ -103,13 +105,25 @@ def deserialize(self, input):
103105 import_log .str = ''
104106 self .areas = {}
105107 self .header .deserialize (input )
108+
109+ # The internal record does not have a length field in it,
110+ # and it is just a byte array. So we have to find the start
111+ # of the next record and slice the input on that boundary.
112+ offsets = self .header .to_dict ()
113+ if "internal_use_offs" in offsets :
114+ internal_use_start = offsets ["internal_use_offs" ]
115+ internal_use_end = next (
116+ (o for o in sorted (offsets .values ()) if o > internal_use_start ), None
117+ )
118+
106119 for k , v in self .header .to_dict ().items ():
107- # Ignore "internal use area"
108- # TODO: Support it as opaque byte array?
109- if v and k != 'internal_use_offs' :
120+ if v :
110121 obj_name = self ._area_table_lookup .inverse [k ]
111122 obj = self .factory (obj_name )
112- obj .deserialize (input [v :])
123+ if k == "internal_use_offs" and internal_use_end is not None :
124+ obj .deserialize (input [v :internal_use_end ])
125+ else :
126+ obj .deserialize (input [v :])
113127 self .areas [obj_name ] = obj
114128
115129 def load_yaml (self , fname ):
0 commit comments