From 1425d543b0759571877e9b79dc6cc860f0bb8267 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 28 May 2024 15:57:47 +1000 Subject: [PATCH 1/2] Added the ability to include logical device properties in the ld ls command via the --properties flag. --- src/python/broker-cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/python/broker-cli.py b/src/python/broker-cli.py index 9ba85829..5d4c9529 100755 --- a/src/python/broker-cli.py +++ b/src/python/broker-cli.py @@ -70,6 +70,7 @@ def str_to_dict(val) -> Dict: ## List logical devices ld_ls_parser = ld_sub_parsers.add_parser('ls', help='list logical devices') +ld_ls_parser.add_argument('--properties', action='store_true', help='Include the properties field in the output', dest='include_props', required=False) ## Create logical devices ld_mk_parser = ld_sub_parsers.add_parser('create', help='create logical device') @@ -294,7 +295,10 @@ def main() -> None: elif args.cmd1 == 'ld': if args.cmd2 == 'ls': devs = dao.get_logical_devices() - tmp_list = list(map(lambda dev: dev.dict(exclude={'properties'}), devs)) + if args.include_props: + tmp_list = list(map(lambda dev: dev.dict(), devs)) + else: + tmp_list = list(map(lambda dev: dev.dict(exclude={'properties'}), devs)) print(pretty_print_json(tmp_list)) elif args.cmd2 == 'create': dev = LogicalDevice.parse_obj(dict_from_file_or_string()) From 534bc6191c9a4b8b97434ada58f1149a4cf34e97 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 4 Jun 2024 15:32:34 +1000 Subject: [PATCH 2/2] DB init script now creates version table so DB v1 backups restore cleanly. --- db/init.d/init_db.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/init.d/init_db.sql b/db/init.d/init_db.sql index a37652c9..304aa48c 100755 --- a/db/init.d/init_db.sql +++ b/db/init.d/init_db.sql @@ -90,7 +90,7 @@ create table if not exists physical_logical_map ( primary key(physical_uid, logical_uid, start_time) ); -create table if not exists users( +create table if not exists users ( uid integer generated always as identity primary key, username text not null unique, salt text not null, @@ -100,11 +100,11 @@ create table if not exists users( read_only boolean default True not null ); +create table if not exists version ( + version integer not null +); + create index if not exists pd_src_id_idx on physical_devices using GIN (source_ids); insert into sources values ('ttn'), ('greenbrain'), ('wombat'), ('ydoc'), ('ict_eagleio'); - --- Enable the PostGIS extensions --- CREATE EXTENSION postgis; --- CREATE EXTENSION postgis_raster; --- CREATE EXTENSION postgis_sfcgal; +insert into version values (1);