Skip to content

Commit

Permalink
[manuf] Add --db-path flag to orchestrator
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Moroze <[email protected]>
  • Loading branch information
nmoroze authored and milesdai committed Dec 3, 2024
1 parent bd89a74 commit cfa534a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 0 additions & 2 deletions sw/host/provisioning/orchestrator/src/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import ot_dut

DEFAULT_DB_FILENAME = "provisioning.sqlite"


@dataclass
class DBConfig(object):
Expand Down
17 changes: 13 additions & 4 deletions sw/host/provisioning/orchestrator/src/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ def main(args_in):
action="store_true",
help="If set, only run CP stage (skips FT and database write).",
)
parser.add_argument(
"--db-path",
required=False,
help=
"Path to provisioning database. The database will be created if it does not exist.",
)
args = parser.parse_args(args_in)

if not args.cp_only and args.db_path is None:
parser.error("--db-path is required when --cp-only is not provided")

# All relative paths are relative to the runfiles directory.
if args.runfiles_dir:
os.chdir(args.runfiles_dir)
Expand Down Expand Up @@ -151,10 +160,6 @@ def main(args_in):
capture_output=True,
text=True).stdout.strip()

db_path = Path(args.log_dir) / db.DEFAULT_DB_FILENAME
db_handle = db.DB(db.DBConfig(db_path=db_path))
db.DeviceRecord.create_table(db_handle)

# Run all provisioning flows.
get_user_confirmation(sku_config, device_id, commit_hash, args)
dut = OtDut(logs_root_dir=args.log_dir,
Expand All @@ -168,6 +173,10 @@ def main(args_in):
if not args.cp_only:
dut.run_ft()

db_path = Path(args.db_path)
db_handle = db.DB(db.DBConfig(db_path=db_path))
db.DeviceRecord.create_table(db_handle)

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 cfa534a

Please sign in to comment.