+ """
+ # pylint: disable=W0613
+ ver = netutils.IPAddress.GetVersionFromAddressFamily(master_params.ip_family)
+ env = {
+ "MASTER_NETDEV": master_params.netdev,
+ "MASTER_IP": master_params.ip,
+ "MASTER_NETMASK": str(master_params.netmask),
+ "CLUSTER_IP_VERSION": str(ver),
+ }
+
+ return env
+
+
+def _RunMasterSetupScript(master_params, action, use_external_mip_script):
+ """Execute the master IP address setup script.
+
+ @type master_params: L{objects.MasterNetworkParameters}
+ @param master_params: network parameters of the master
+ @type action: string
+ @param action: action to pass to the script. Must be one of
+ L{backend._MASTER_START} or L{backend._MASTER_STOP}
+ @type use_external_mip_script: boolean
+ @param use_external_mip_script: whether to use an external master IP
+ address setup script
+ @raise backend.RPCFail: if there are errors during the execution of the
+ script
+
+ """
+ env = _BuildMasterIpEnv(master_params)
+
+ if use_external_mip_script:
+ setup_script = constants.EXTERNAL_MASTER_SETUP_SCRIPT
+ else:
+ setup_script = constants.DEFAULT_MASTER_SETUP_SCRIPT
+
+ result = utils.RunCmd([setup_script, action], env=env, reset_env=True)
+
+ if result.failed:
+ _Fail("Failed to %s the master IP. Script return value: %s" %
+ (action, result.exit_code), log=True)
+
+
+@RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
+ _BuildMasterIpEnv)
+def ActivateMasterIp(master_params, use_external_mip_script):
+ """Activate the IP address of the master daemon.
+
+ @type master_params: L{objects.MasterNetworkParameters}
+ @param master_params: network parameters of the master
+ @type use_external_mip_script: boolean
+ @param use_external_mip_script: whether to use an external master IP
+ address setup script
+ @raise RPCFail: in case of errors during the IP startup
+
+ """
+ _RunMasterSetupScript(master_params, _MASTER_START,
+ use_external_mip_script)
+
+
+def StartMasterDaemons(no_voting):