#!/usr/bin/python
#
-# Copyright (C) 2010 Google Inc.
+# Copyright (C) 2010, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
from ganeti import errors
from ganeti import ssh
from ganeti import utils
+from ganeti import pathutils
_GROUPS_MERGE = "merge"
utils.WriteFile(key_path, mode=0600, data=result.stdout)
result = self._RunCmd(cluster, "gnt-node list -o name,offline"
- " --no-header --separator=,", private_key=key_path)
+ " --no-headers --separator=,", private_key=key_path)
if result.failed:
raise errors.RemoteError("Unable to retrieve list of nodes from %s."
" Fail reason: %s; output: %s" %
(cluster, result.fail_reason, result.output))
- nodes_statuses = [line.split(',') for line in result.stdout.splitlines()]
+ nodes_statuses = [line.split(",") for line in result.stdout.splitlines()]
nodes = [node_status[0] for node_status in nodes_statuses
if node_status[1] == "N"]
- result = self._RunCmd(cluster, "gnt-instance list -o name --no-header",
+ result = self._RunCmd(cluster, "gnt-instance list -o name --no-headers",
private_key=key_path)
if result.failed:
raise errors.RemoteError("Unable to retrieve list of instances from"
(cluster, result.fail_reason, result.output))
instances = result.stdout.splitlines()
- path = utils.PathJoin(constants.DATA_DIR, "ssconf_%s" %
+ path = utils.PathJoin(pathutils.DATA_DIR, "ssconf_%s" %
constants.SS_MASTER_NODE)
result = self._RunCmd(cluster, "cat %s" % path, private_key=key_path)
if result.failed:
"""
for _ in range(max_attempts):
result = self.ssh_runner.Run(hostname=hostname, command=command,
- user=user, use_cluster_key=use_cluster_key,
- strict_host_check=strict_host_check,
- private_key=private_key, batch=batch,
- ask_key=ask_key)
+ user=user, use_cluster_key=use_cluster_key,
+ strict_host_check=strict_host_check,
+ private_key=private_key, batch=batch,
+ ask_key=ask_key)
if not result.failed:
break
"""
for data in self.merger_data:
result = self._RunCmd(data.master_node,
- "gnt-cluster deactivate-master-ip")
+ "gnt-cluster deactivate-master-ip --yes")
if result.failed:
raise errors.RemoteError("Unable to remove master IP on %s."
"""Stop all daemons on merging nodes.
"""
- cmd = "%s stop-all" % constants.DAEMON_UTIL
+ cmd = "%s stop-all" % pathutils.DAEMON_UTIL
for data in self.merger_data:
for node in data.nodes:
result = self._RunCmd(node, cmd, max_attempts=3)
"""
for data in self.merger_data:
result = self._RunCmd(data.cluster, "cat %s" %
- constants.CLUSTER_CONF_FILE)
+ pathutils.CLUSTER_CONF_FILE)
if result.failed:
raise errors.RemoteError("Unable to retrieve remote config on %s."
@raise errors.CommandError: If unable to kill
"""
- result = utils.RunCmd([constants.DAEMON_UTIL, "stop-master"])
+ result = utils.RunCmd([pathutils.DAEMON_UTIL, "stop-master"])
if result.failed:
raise errors.CommandError("Unable to stop master daemons."
" Fail reason: %s; output: %s" %
if no_vote:
env["EXTRA_MASTERD_ARGS"] = "--no-voting --yes-do-it"
- result = utils.RunCmd([constants.DAEMON_UTIL, "start-master"], env=env)
+ result = utils.RunCmd([pathutils.DAEMON_UTIL, "start-master"], env=env)
if result.failed:
raise errors.CommandError("Couldn't start ganeti master."
" Fail reason: %s; output: %s" %
"""
for data in self.merger_data:
for node in data.nodes:
+ logging.info("Readding node %s", node)
result = utils.RunCmd(["gnt-node", "add", "--readd",
"--no-ssh-key-check", "--force-join", node])
if result.failed:
if result.failed:
raise errors.CommandError("Redistribution failed. Fail reason: %s;"
" output: %s" % (result.fail_reason,
- result.output))
+ result.output))
# R0201: Method could be a function
def _StartupAllInstances(self): # pylint: disable=R0201
rbsteps.append("Restore %s from another master candidate"
" and restart master daemon" %
- constants.CLUSTER_CONF_FILE)
+ pathutils.CLUSTER_CONF_FILE)
self._MergeConfig()
self._StartMasterDaemon(no_vote=True)