Skip to content

Commit

Permalink
Add enclosure open/close endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jun 15, 2024
1 parent 10af786 commit d76706d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/lvmapi/routers/enclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,30 @@ async def status() -> EnclosureStatus:
}

return EnclosureStatus(**status_data)


@router.route("/open")
async def open_enclosure(force:bool=False):
"""Opens the enclosure."""

force_flag = "--force" if force else ""

try:
await send_clu_command(f"lvmecp dome open {force_flag}")
except Exception as ee:
raise HTTPException(status_code=500, detail=str(ee))

return True

@router.route("/close")
async def close_enclosure(force:bool=False):
"""Closes the enclosure."""

force_flag = "--force" if force else ""

try:
await send_clu_command(f"lvmecp dome close {force_flag}")
except Exception as ee:
raise HTTPException(status_code=500, detail=str(ee))

return True

0 comments on commit d76706d

Please sign in to comment.