Skip to content

Commit

Permalink
contrib/sync-places: Update for grpc
Browse files Browse the repository at this point in the history
Update this script so that it works with the grpc-based labgrid.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Jul 29, 2024
1 parent e344fa7 commit 841f14d
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions contrib/sync-places.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ async def do_sync(session, args):
for name in remove_places:
print(f"Removing place {name}")
if not args.dry_run:
await session.call("org.labgrid.coordinator.del_place", name)
await session.run_del_place(name)
changed = True

for name in config["places"]:
if not name in seen_places:
print(f"Adding place {name}")
if not args.dry_run:
await session.call("org.labgrid.coordinator.add_place", name)
await session.run_add_place(name)
changed = True

for name in config["places"]:
Expand Down Expand Up @@ -89,9 +89,7 @@ async def do_sync(session, args):
else:
print(f"Deleting match '{match}' for place {name}")
if not args.dry_run:
await session.call(
"org.labgrid.coordinator.del_place_match", name, match, rename
)
await session.run_del_match(name, match, rename)
changed = True

for m in matches:
Expand All @@ -103,9 +101,7 @@ async def do_sync(session, args):
print(f"Adding match '{match}' for place {name}")

if not args.dry_run:
await session.call(
"org.labgrid.coordinator.add_place_match", name, match, rename
)
await session.run_add_match(name, match, rename)
changed = True

tags = config["places"][name].get("tags", {}).copy()
Expand All @@ -131,9 +127,7 @@ async def do_sync(session, args):
tags[k] = ""

if not args.dry_run:
await session.call(
"org.labgrid.coordinator.set_place_tags", name, tags
)
await session.run_set_tags(name, tags)
changed = True

async def do_dump(session, args):
Expand Down Expand Up @@ -177,7 +171,7 @@ async def do_dump(session, args):
"--crossbar",
"-x",
metavar="URL",
default=os.environ.get("LG_CROSSBAR", "ws://127.0.0.1:20408/ws"),
default=os.environ.get("LG_COORDINATOR", "ws://127.0.0.1:20408/ws"),
help="Crossbar websocket URL (default: %(default)s)",
)
parser.add_argument("--proxy", "-P", help="Proxy connections via given ssh host")
Expand Down Expand Up @@ -219,8 +213,11 @@ async def do_dump(session, args):
if args.proxy:
proxymanager.force_proxy(args.proxy)

extra = {
'env': None,
}
session = start_session(
args.crossbar, os.environ.get("LG_CROSSBAR_REALM", "realm1"), {}
args.crossbar, extra
)

return session.loop.run_until_complete(args.func(session, args))
Expand Down

0 comments on commit 841f14d

Please sign in to comment.