change integer for string in firewire bios

This commit is contained in:
Cayo Puigdefabregas 2022-03-29 12:23:51 +02:00
parent f3e8fa6cc1
commit 90dea5492e
5 changed files with 44 additions and 5 deletions

View File

@ -0,0 +1,36 @@
"""change firewire
Revision ID: 17288b2a7440
Revises: 8571fb32c912
Create Date: 2022-03-29 11:49:39.270791
"""
from alembic import op, context
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
import citext
# revision identifiers, used by Alembic.
revision = '17288b2a7440'
down_revision = '8571fb32c912'
branch_labels = None
depends_on = None
def get_inv():
INV = context.get_x_argument(as_dictionary=True).get('inventory')
if not INV:
raise ValueError("Inventory value is not specified")
return INV
def upgrade():
op.alter_column('motherboard', 'firewire', citext.CIText(), schema=f'{get_inv()}')
op.add_column('computer', sa.Column('uuid', postgresql.UUID(as_uuid=True),
nullable=True),
schema=f'{get_inv()}')
def downgrade():
op.alter_column('motherboard', 'firewire', sa.SmallInteger(), schema=f'{get_inv()}')

View File

@ -319,7 +319,7 @@ class Motherboard(Component):
super().__init__(node)
self.from_lshw(node)
self.usb = self.num_interfaces(node, 'usb')
self.firewire = self.num_interfaces(node, 'firewire')
self.firewire = str(self.num_interfaces(node, 'firewire'))
self.serial = self.num_interfaces(node, 'serial')
self.pcmcia = self.num_interfaces(node, 'pcmcia')
self.slots = int(2)

View File

@ -136,7 +136,7 @@ class ParseSnapshot:
return self.dmi.get("BIOS")[0].get("Release Date", self.default)
def get_firmware(self):
return int(float(self.dmi.get("BIOS")[0].get("Firmware Revision", 1)))
return self.dmi.get("BIOS")[0].get("Firmware Revision", '1')
def get_max_ram_size(self):
size = 0
@ -354,8 +354,8 @@ class ParseSnapshotLsHw:
def set_basic_datas(self):
pc, self.components_obj = Computer.run(self.lshw_raw, self.hwinfo_raw)
# import pdb; pdb.set_trace()
self.device = pc.dump()
self.device['uuid'] = self.dmi.get("System")[0].get("UUID")
def set_components(self):
memory = None

View File

@ -663,6 +663,7 @@ class Computer(Device):
db.ForeignKey(User.id),
nullable=True)
receiver = db.relationship(User, primaryjoin=receiver_id == User.id)
uuid = db.Column(UUID(as_uuid=True), nullable=True)
def __init__(self, *args, **kwargs) -> None:
if args:
@ -955,7 +956,7 @@ class Motherboard(JoinedComponentTableMixin, Component):
slots = Column(SmallInteger, check_range('slots', min=0))
slots.comment = """PCI slots the motherboard has."""
usb = Column(SmallInteger, check_range('usb', min=0))
firewire = Column(SmallInteger, check_range('firewire', min=0))
firewire = Column(CIText())
serial = Column(SmallInteger, check_range('serial', min=0))
pcmcia = Column(SmallInteger, check_range('pcmcia', min=0))
bios_date = Column(db.Date)

View File

@ -136,6 +136,7 @@ class Computer(Device):
owner_id = UUID(data_key='ownerID')
transfer_state = EnumField(enums.TransferState, description=m.Computer.transfer_state.comment)
receiver_id = UUID(data_key='receiverID')
uuid = UUID(required=False)
class Desktop(Computer):
@ -271,7 +272,8 @@ class Motherboard(Component):
slots = Integer(validate=Range(0, 20),
description=m.Motherboard.slots.comment)
usb = Integer(validate=Range(0, 20), description=m.Motherboard.usb.comment)
firewire = Integer(validate=Range(0, 20), description=m.Motherboard.firewire.comment)
# firewire = Integer(validate=Range(0, 20), description=m.Motherboard.firewire.comment)
firewire = String(description=m.Motherboard.firewire.comment)
serial = Integer(validate=Range(0, 20), description=m.Motherboard.serial.comment)
pcmcia = Integer(validate=Range(0, 20), description=m.Motherboard.pcmcia.comment)
bios_date = Date(validate=Range(datetime.date(year=1980, month=1, day=1),