Migrate PC form + collector off legacy Machine onto the asset/computer model
- PCForm saves/loads via computersApi (asset core + computer extension + primary IP in one call); PC Type now uses the dedicated computertypes table instead of MachineType, fixing the cross-table id mismatch. - Collector (/api/collector/*) writes the Computer model: lookup by hostname or asset number, update loggedinuser/lastreporteddate/lastboottime + asset serial, installed apps via ComputerInstalledApp. - Add computers.vendorid + modelnumberid (PCs carry make/model) and computerinstalledapps.installedversion; computer GET now includes communications. Wire COLLECTOR_API_KEY into config. Retires the last write paths to the Machine model for PCs (ADR-001). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,18 @@ class Computer(BaseModel):
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Hardware make/model (PCs carry vendor + model like equipment)
|
||||
vendorid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('vendors.vendorid'),
|
||||
nullable=True
|
||||
)
|
||||
modelnumberid = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('models.modelnumberid'),
|
||||
nullable=True
|
||||
)
|
||||
|
||||
# Status tracking
|
||||
loggedinuser = db.Column(db.String(100), nullable=True)
|
||||
lastreporteddate = db.Column(db.DateTime, nullable=True)
|
||||
@@ -93,6 +105,8 @@ class Computer(BaseModel):
|
||||
)
|
||||
computertype = db.relationship('ComputerType', backref='computers')
|
||||
operatingsystem = db.relationship('OperatingSystem', backref='computers')
|
||||
vendor = db.relationship('Vendor')
|
||||
model = db.relationship('Model')
|
||||
|
||||
# Installed applications (one-to-many)
|
||||
installedapps = db.relationship(
|
||||
@@ -120,6 +134,10 @@ class Computer(BaseModel):
|
||||
result['computertypename'] = self.computertype.computertype
|
||||
if self.operatingsystem:
|
||||
result['osname'] = self.operatingsystem.osname
|
||||
if self.vendor:
|
||||
result['vendorname'] = self.vendor.vendor
|
||||
if self.model:
|
||||
result['modelname'] = self.model.modelnumber
|
||||
|
||||
return result
|
||||
|
||||
@@ -149,6 +167,8 @@ class ComputerInstalledApp(db.Model):
|
||||
db.ForeignKey('appversions.appversionid'),
|
||||
nullable=True
|
||||
)
|
||||
# Raw version string from automated collection (when no curated AppVersion)
|
||||
installedversion = db.Column(db.String(100), nullable=True)
|
||||
isactive = db.Column(db.Boolean, default=True, nullable=False)
|
||||
installeddate = db.Column(db.DateTime, default=db.func.now())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user