Skip to content

Commit

Permalink
[orchestrator] check if device ID exists in database before writing
Browse files Browse the repository at this point in the history
This updates the orchestrator to check if a device ID already exists in
the database before attempting to update the entry.

Signed-off-by: Tim Trippel <[email protected]>
  • Loading branch information
timothytrippel committed Jan 15, 2025
1 parent 851576b commit 5b81ae1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sw/host/provisioning/orchestrator/src/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,20 @@ def main(args_in):
if args.cp_only:
logging.info("FT skipped since --cp-only was provided")
return

dut.run_ft()

# Open the local SQLite registry database.
db_path = Path(args.db_path)
db_handle = db.DB(db.DBConfig(db_path=db_path))
db.DeviceRecord.create_table(db_handle)

# Check device ID exists in the database.
if db.DeviceRecord.query(db_handle, dut.device_id.to_hexstr()) is not None:
logging.warning(
"DeviceId already exists in database. Overwrite record?")
confirm()

# Register the DUT in the database.
device_record = db.DeviceRecord.from_dut(dut)
device_record.upsert(db_handle)
logging.info(f"Added DeviceRecord to database: {device_record}")
Expand Down

0 comments on commit 5b81ae1

Please sign in to comment.