[autotest] Add atest stable_version command to manage stable versions.
Add a decorator require_confirmation to atest, any delete action will prompt
for confirmation, use option --no-confirmation to skip that. It's applicable
to command like atest label delete, atest host delete.
Add 3 actions for topic stable_version:
list: Show version of a given board or list all boards and their stable
versions if --board option is not specified.
$ ./atest stable_version list
==============================
board | version
------------------------------
DEFAULT | R41-4687.0.0
peppy | R40-4555.0.0
==============================
modify: Set the stable version of a given board to the given value.
$ ./atest stable_version modify -b peppy -i R40-4515.0.0
Stable version for board peppy is changed from R40-4555.0.0.0 to R40-4515.0.0.
delete: Delete the stable version of a given board. So its stable version will
use the value for board `DEFAULT`.
$ ./atest stable_version delete -b peppy
Are you sure to delete stable version for board peppy? After this action is
done, stable version for board peppy will be R41.0.0.0
Continue? [y/N] y
Stable version for board peppy is deleted.
DEPLOY=apache
BUG=chromium:436656
TEST=local setup, unittest
Change-Id: I31047740a4886854aa653b1bf0f16c5f5c7a3f14
Reviewed-on: https://chromium-review.googlesource.com/236951
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
Trybot-Ready: Dan Shi <dshi@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 025c087..dc097b3 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -490,4 +490,32 @@
of CROS.stable_cros_version if stable_versinos table does not have
entry of board DEFAULT.
"""
- return stable_version_utils.get_version(board)
+ return stable_version_utils.get(board)
+
+
+def get_all_stable_versions():
+ """Get stable versions for all boards.
+
+ @return: A dictionary of board:version.
+ """
+ return stable_version_utils.get_all()
+
+
+def set_stable_version(version, board=stable_version_utils.DEFAULT):
+ """Modify stable version for the given board.
+
+ @param version: The new value of stable version for given board.
+ @param board: Name of the board, default to value `DEFAULT`.
+ """
+ stable_version_utils.set(version=version, board=board)
+
+
+def delete_stable_version(board):
+ """Modify stable version for the given board.
+
+ Delete a stable version entry in afe_stable_versions table for a given
+ board, so default stable version will be used.
+
+ @param board: Name of the board.
+ """
+ stable_version_utils.delete(board=board)