[autotest] Forward RPCs that update host labels to shards
Other than label_add_hosts and label_remove_hosts,
we have 2 more RPCs that updates host labels.
They are host_add_labels and host_remove_labels.
These RPCs should be forwarded to shards.
BUG=chromium:497887
TEST=puppylab. test_host13 is a host in a shard.
>>> import common
>>> from autotest_lib.server import frontend
>>> afe = frontend.AFE()
>>> h = afe.get_hosts(['test_host13'])[0]
>>> h.add_labels(['l1','l3'])
Adding labels ['l1', 'l3'] to host test_host13
>>> h.remove_labels(['l1'])
DEPLOY=apache
Change-Id: Ic37c026efa009eff3aa5276cbbef8c3e1d62e508
Reviewed-on: https://chromium-review.googlesource.com/276211
Reviewed-by: Mungyung Ryu <mkryu@google.com>
Commit-Queue: Mungyung Ryu <mkryu@google.com>
Tested-by: Mungyung Ryu <mkryu@google.com>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 0cd3739..5885e88 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -496,6 +496,7 @@
return [s.get_details() for s in servers]
+@rpc_utils.route_rpc_to_master
def get_stable_version(board=stable_version_utils.DEFAULT):
"""Get stable version for the given board.
@@ -504,36 +505,29 @@
of CROS.stable_cros_version if stable_versinos table does not have
entry of board DEFAULT.
"""
- # This RPC call should be accepted only by master.
- if utils.is_shard():
- return rpc_utils.route_rpc_to_master('get_stable_version', board=board)
return stable_version_utils.get(board)
+@rpc_utils.route_rpc_to_master
def get_all_stable_versions():
"""Get stable versions for all boards.
@return: A dictionary of board:version.
"""
- # This RPC call should be accepted only by master.
- if utils.is_shard():
- return rpc_utils.route_rpc_to_master('get_all_stable_versions')
return stable_version_utils.get_all()
+@rpc_utils.route_rpc_to_master
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`.
"""
- # This RPC call should be accepted only by master.
- if utils.is_shard():
- return rpc_utils.route_rpc_to_master('set_stable_version',
- version=version, board=board)
stable_version_utils.set(version=version, board=board)
+@rpc_utils.route_rpc_to_master
def delete_stable_version(board):
"""Modify stable version for the given board.
@@ -542,10 +536,6 @@
@param board: Name of the board.
"""
- # This RPC call should be accepted only by master.
- if utils.is_shard():
- return rpc_utils.route_rpc_to_master('delete_stable_version',
- board=board)
stable_version_utils.delete(board=board)