change integer for string in firewire bios
This commit is contained in:
parent
f3e8fa6cc1
commit
90dea5492e
|
@ -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()}')
|
|
@ -319,7 +319,7 @@ class Motherboard(Component):
|
||||||
super().__init__(node)
|
super().__init__(node)
|
||||||
self.from_lshw(node)
|
self.from_lshw(node)
|
||||||
self.usb = self.num_interfaces(node, 'usb')
|
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.serial = self.num_interfaces(node, 'serial')
|
||||||
self.pcmcia = self.num_interfaces(node, 'pcmcia')
|
self.pcmcia = self.num_interfaces(node, 'pcmcia')
|
||||||
self.slots = int(2)
|
self.slots = int(2)
|
||||||
|
|
|
@ -136,7 +136,7 @@ class ParseSnapshot:
|
||||||
return self.dmi.get("BIOS")[0].get("Release Date", self.default)
|
return self.dmi.get("BIOS")[0].get("Release Date", self.default)
|
||||||
|
|
||||||
def get_firmware(self):
|
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):
|
def get_max_ram_size(self):
|
||||||
size = 0
|
size = 0
|
||||||
|
@ -354,8 +354,8 @@ class ParseSnapshotLsHw:
|
||||||
|
|
||||||
def set_basic_datas(self):
|
def set_basic_datas(self):
|
||||||
pc, self.components_obj = Computer.run(self.lshw_raw, self.hwinfo_raw)
|
pc, self.components_obj = Computer.run(self.lshw_raw, self.hwinfo_raw)
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
self.device = pc.dump()
|
self.device = pc.dump()
|
||||||
|
self.device['uuid'] = self.dmi.get("System")[0].get("UUID")
|
||||||
|
|
||||||
def set_components(self):
|
def set_components(self):
|
||||||
memory = None
|
memory = None
|
||||||
|
|
|
@ -663,6 +663,7 @@ class Computer(Device):
|
||||||
db.ForeignKey(User.id),
|
db.ForeignKey(User.id),
|
||||||
nullable=True)
|
nullable=True)
|
||||||
receiver = db.relationship(User, primaryjoin=receiver_id == User.id)
|
receiver = db.relationship(User, primaryjoin=receiver_id == User.id)
|
||||||
|
uuid = db.Column(UUID(as_uuid=True), nullable=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
if args:
|
if args:
|
||||||
|
@ -955,7 +956,7 @@ class Motherboard(JoinedComponentTableMixin, Component):
|
||||||
slots = Column(SmallInteger, check_range('slots', min=0))
|
slots = Column(SmallInteger, check_range('slots', min=0))
|
||||||
slots.comment = """PCI slots the motherboard has."""
|
slots.comment = """PCI slots the motherboard has."""
|
||||||
usb = Column(SmallInteger, check_range('usb', min=0))
|
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))
|
serial = Column(SmallInteger, check_range('serial', min=0))
|
||||||
pcmcia = Column(SmallInteger, check_range('pcmcia', min=0))
|
pcmcia = Column(SmallInteger, check_range('pcmcia', min=0))
|
||||||
bios_date = Column(db.Date)
|
bios_date = Column(db.Date)
|
||||||
|
|
|
@ -136,6 +136,7 @@ class Computer(Device):
|
||||||
owner_id = UUID(data_key='ownerID')
|
owner_id = UUID(data_key='ownerID')
|
||||||
transfer_state = EnumField(enums.TransferState, description=m.Computer.transfer_state.comment)
|
transfer_state = EnumField(enums.TransferState, description=m.Computer.transfer_state.comment)
|
||||||
receiver_id = UUID(data_key='receiverID')
|
receiver_id = UUID(data_key='receiverID')
|
||||||
|
uuid = UUID(required=False)
|
||||||
|
|
||||||
|
|
||||||
class Desktop(Computer):
|
class Desktop(Computer):
|
||||||
|
@ -271,7 +272,8 @@ class Motherboard(Component):
|
||||||
slots = Integer(validate=Range(0, 20),
|
slots = Integer(validate=Range(0, 20),
|
||||||
description=m.Motherboard.slots.comment)
|
description=m.Motherboard.slots.comment)
|
||||||
usb = Integer(validate=Range(0, 20), description=m.Motherboard.usb.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)
|
serial = Integer(validate=Range(0, 20), description=m.Motherboard.serial.comment)
|
||||||
pcmcia = Integer(validate=Range(0, 20), description=m.Motherboard.pcmcia.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),
|
bios_date = Date(validate=Range(datetime.date(year=1980, month=1, day=1),
|
||||||
|
|
Reference in New Issue