On 07/17/2017 06:36 PM, Dan Callaghan wrote:
Excerpts from Shawn Doherty's message of 2017-07-14 09:17
-04:00:
> Hello all.. apologies if zombie thread is inappropriate but I'd like to
> revisit this conversation regarding firmware information being included.
>
> We have started a patch to display firmware and date and are hoping to get
> some input on progressing. What we were last discussing was to update the
> device table. I'm also curious about a migration script. Here is what we
> have so far.
>
>
> Thanks for looking. Shawn.
Might be easier to read this if you post it to Gerrit. There is no harm
in posting a WIP or draft patch to Gerrit and asking for reviews on
there.
> diff --git a/Server/bkr/server/controllers.py
> b/Server/bkr/server/controllers.py
> index cece8db..32dc0d4 100644
> --- a/Server/bkr/server/controllers.py
> +++ b/Server/bkr/server/controllers.py
> @@ -123,9 +123,11 @@ def default(self, *args, **kw):
> widgets.PaginateDataGrid.Column(name='driver',
> getter=lambda x: x.driver, title='Driver', options=dict(sortable=True)),
> widgets.PaginateDataGrid.Column(name='vendor_id',
> getter=lambda x: x.vendor_id, title='Vendor ID',
> options=dict(sortable=True)),
> widgets.PaginateDataGrid.Column(name='device_id',
> getter=lambda x: x.device_id, title='Device ID',
> options=dict(sortable=True)),
> -
> widgets.PaginateDataGrid.Column(name='subsys_vendor_id', getter=lambda x:
> x.subsys_vendor_id, title='Subsys Vendor ID', options=dict(sortable=True)),
> + widgets.PaginateDataGrid.Column(name='subsys_vendor_id',
> getter=lambda x: x.subsys_vendor_id, title='Subsys Vendor ID',
> options=dict(sortable=True)),
>
> widgets.PaginateDataGrid.Column(name='subsys_device_id', getter=lambda x:
> x.subsys_device_id, title='Subsys Device ID', options=dict(sortable=True)),
> - ])
> +
> widgets.PaginateDataGrid.Column(name='subsys_device_id', getter=lambda x:
> x.fw_version, title='Firmware Version', options=dict(sortable=True)),
> ++
> widgets.PaginateDataGrid.Column(name='subsys_device_id', getter=lambda x:
> x.fw_date, title='Firmware Date', options=dict(sortable=True)),
> + ])
You'll want to fix the column name and title on these. Name can be
anything but by convention it should match the db column. It's used for
sorting inside the widget.
> return dict(title="Devices",
> grid = devices_grid,
> search_bar=None,
> diff --git a/Server/bkr/server/model/inventory.py
> b/Server/bkr/server/model/inventory.py
> index ecbc073..88301ae 100644
> --- a/Server/bkr/server/model/inventory.py
> +++ b/Server/bkr/server/model/inventory.py
> @@ -297,6 +297,8 @@ class System(DeclarativeMappedObject, ActivityMixin):
> kernel_type_id = Column(Integer, ForeignKey('kernel_type.id'),
> default=select([KernelType.id],
> limit=1).where(KernelType.kernel_type==u'default').correlate(None),
> nullable=False)
> + fw_version = Column(String(32))
> + fw_date = Column(DateTime, default=None)
> kernel_type = relationship('KernelType')
> devices = relationship('Device', secondary=system_device_map,
> back_populates='systems')
It looks like these are new columns on System, but they should actually
be new columns on Device, right?
We need two sets of firmware info, system level info to track what
version of BIOS0 is installed on a machine, these entries here. And
device level info to track what firmware, if any, is on a given PCI
connected device, the additions below. It is currently our understanding
that the layout is something like
system_entry -> device_entry
device_entry
A system_entry exists in a different table from device_entries hence why
we decided to use two different sets of data, thus the two changes.
Maybe I misunderstood the DB schema and device entries are reused for a
singular machine entry?
The catch for the system level firmware is it must be directly
associated with a given FQDN, i.e. it is a property of an FQDN.
Hopefully this makes a little more sense as to why there are two sets of
firmware entries, it was intentional - maybe not needed :-D
> @@ -2362,6 +2371,8 @@ class Device(DeclarativeMappedObject):
> device_class = relationship(DeviceClass)
> date_added = Column(DateTime, default=datetime.utcnow, nullable=False)
> systems = relationship(System, secondary=system_device_map,
> back_populates='devices')
> + fw_version = Column(String(32))
> + fw_date = Column(DateTime, default=None)
... oh never mind, they are here too. :-) So I guess just remove the
ones above on System.
We probably want Date not Datetime as the type for the fw_date column (I
assume no firmware reports its build date down to the second).
Is 32 chars enough for the version string? We can always expand it
later. Does lshw itself have any length limits/expectations for the
firmware version?
Good question, lshw has a char array of 32 for network device firmware,
network devices were the initial set of devices we had considered:
in core/network.cc:
82 struct ethtool_drvinfo
83 {
84 u32 cmd;
85 char driver[32]; /* driver short
name, "tulip", "eepro100" */
86 char version[32]; /* driver
version string */
87 char fw_version[32]; /* firmware
version string, if applicable */
88 char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for
this IF. */
> diff --git a/systemscan/main.py b/systemscan/main.py
> index 64b9312..41895f2 100755
> --- a/systemscan/main.py
> +++ b/systemscan/main.py
> @@ -286,6 +286,14 @@ def read_inventory(inventory, arch = None,
> proc_cpuinfo='/proc/cpuinfo'):
>
> #Break the xml into the relevant sets of data
> cpuinfo = inventory.xpath(".//node[@class='processor']")[0]
> +
> + #system firmware info
> + sysfwinfo = inventory.xpath('.//node[@id="firmware"]')[0]
> + #create dictionary with key-values for version and date
> + SystemFirmware = dict(version = sysfwinfo.findtext('version'), date =
> sysfwinfo.findtext('date'))
> + #add to data
> + data['SystemFirmware'] = SystemFirmware
> +
I guess this is not quite the right place... There is a loop starting
line 492:
for device in devices:
where it compiles the list of devices with the properties for each one.
I guess you would just fill in fw_version and fw_date there, whenever
the values exist.
_______________________________________________
Beaker-devel mailing list -- beaker-devel(a)lists.fedorahosted.org
To unsubscribe send an email to beaker-devel-leave(a)lists.fedorahosted.org