On Tue, Oct 25, 2011 at 09:10:24PM +0200, Michael Hanselmann wrote:
> With this patch, only 6 RPC are left as old-style code.
> ---
> lib/bootstrap.py | 14 +++--
> lib/build/rpc_definitions.py | 19 +++++++
> lib/rpc.py | 117 ++++++++++-------------------------------
> lib/server/masterd.py | 2 +-
> test/ganeti.rpc_unittest.py | 13 +++--
> 5 files changed, 65 insertions(+), 100 deletions(-)
>
> diff --git a/lib/bootstrap.py b/lib/bootstrap.py
> index 2f720a2..2c73bca 100644
> --- a/lib/bootstrap.py
> +++ b/lib/bootstrap.py
> @@ -222,7 +222,7 @@ def _WaitForNodeDaemon(node_name):
>
> """
> def _CheckNodeDaemon():
> - result = rpc.RpcRunner.call_version([node_name])[node_name]
> + result = rpc.BootstrapRunner().call_version([node_name])[node_name]
> if result.fail_msg:
> raise utils.RetryAgain()
>
> @@ -565,11 +565,12 @@ def FinalizeClusterDestroy(master):
> """
> cfg = config.ConfigWriter()
> modify_ssh_setup = cfg.GetClusterInfo().modify_ssh_setup
> - result = rpc.RpcRunner.call_node_stop_master(master)
> + result = rpc.BootstrapRunner().call_node_stop_master(master)
> msg = result.fail_msg
> if msg:
> logging.warning("Could not disable the master role: %s", msg)
> - result = rpc.RpcRunner.call_node_leave_cluster(master, modify_ssh_setup)
> + result = rpc.BootstrapRunner().call_node_leave_cluster(master,
> + modify_ssh_setup)
> msg = result.fail_msg
> if msg:
> logging.warning("Could not shutdown the node daemon and cleanup"
> @@ -697,7 +698,7 @@ def MasterFailover(no_voting=False):
>
> logging.info("Stopping the master daemon on node %s", old_master)
>
> - result = rpc.RpcRunner.call_node_stop_master(old_master)
> + result = rpc.BootstrapRunner().call_node_stop_master(old_master)
> msg = result.fail_msg
> if msg:
> logging.error("Could not disable the master role on the old master"
> @@ -726,7 +727,8 @@ def MasterFailover(no_voting=False):
>
> logging.info("Starting the master daemons on the new master")
>
> - result = rpc.RpcRunner.call_node_start_master_daemons(new_master,
> no_voting)
> + result = rpc.BootstrapRunner().call_node_start_master_daemons(new_master,
> + no_voting)
> msg = result.fail_msg
> if msg:
> logging.error("Could not start the master role on the new master"
> @@ -782,7 +784,7 @@ def GatherMasterVotes(node_list):
> if not node_list:
> # no nodes left (eventually after removing myself)
> return []
> - results = rpc.RpcRunner.call_master_info(node_list)
> + results = rpc.BootstrapRunner().call_master_info(node_list)
> if not isinstance(results, dict):
> # this should not happen (unless internal error in rpc)
> logging.critical("Can't complete rpc call, aborting master startup")
> diff --git a/lib/build/rpc_definitions.py b/lib/build/rpc_definitions.py
> index 930200b..b4bb39e 100644
> --- a/lib/build/rpc_definitions.py
> +++ b/lib/build/rpc_definitions.py
> @@ -371,4 +371,23 @@ CALLS = {
> ("rename", None, None),
> ], None, "Rename job queue file"),
> ],
> + "RpcClientBootstrap": [
> + ("node_start_master_daemons", SINGLE, TMO_FAST, [
> + ("no_voting", None, None),
> + ], None, "Starts master daemons on a node"),
> + ("node_activate_master_ip", SINGLE, TMO_FAST, [], None,
> + "Activates master IP on a node"),
> + ("node_stop_master", SINGLE, TMO_FAST, [], None,
> + "Deactivates master IP and stops master daemons on a node"),
> + ("node_deactivate_master_ip", SINGLE, TMO_FAST, [], None,
> + "Deactivates master IP on a node"),
> + ("node_change_master_netmask", SINGLE, TMO_FAST, [
> + ("netmask", None, None),
> + ], None, "Change master IP netmask"),
FYI, this call is not used from bootstrap, so it should be moved to the
standard RPC client.
There are some other calls that are used only from bootstrap, but that's
harder to cleanup.
LGTM.
iustin