[autotest] Require lock reason to lock device
When locking a device, a locking reason now must be provided.
This applies to both adding a new device, and modifying an
existing device from both the web frontend and the atest
command-line tool.
BUG=chromium:336805
DEPLOY=migrate
TEST=Tested adding locked/unlocked devices and locking/unlocking devices
from both the web frontend and using the 'atest host ...' command-line tools.
Change-Id: I3a8cd8891a2999f026dd709ae8a79e2b8cbc251a
Reviewed-on: https://chromium-review.googlesource.com/267595
Tested-by: Matthew Sartori <msartori@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Matthew Sartori <msartori@chromium.org>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index dafa432..fd3b645 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -440,6 +440,7 @@
@param update_data: A dictionary with the changes to make to the host.
"""
locked = update_data.get('locked', None)
+ lock_reason = update_data.get('lock_reason', None)
if locked is not None:
if locked and host.locked:
raise model_logic.ValidationError({
@@ -448,6 +449,9 @@
if not locked and not host.locked:
raise model_logic.ValidationError({
'locked': 'Host already unlocked.'})
+ if locked and not lock_reason and not host.locked:
+ raise model_logic.ValidationError({
+ 'locked': 'Please provide a reason for locking'})
def get_motd():