From 93e4c50bde8c979e88ae67301fcf7b5aa1fcdc07 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 10 Apr 2008 17:03:38 +0000 Subject: [PATCH] Verify: add instance information to node_info With this patch node_info is changed to store information about which primary and secondary instances are configured on a node. This information is useful to check memory and disk allocation. A list of non-redundant instances is also collected at this stage. Reviewed-by: iustinp --- lib/cmdlib.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 3399b2c40..dbfc83a2e 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -765,6 +765,7 @@ class LUVerifyCluster(NoHooksLU): vg_name = self.cfg.GetVGName() nodelist = utils.NiceSort(self.cfg.GetNodeList()) instancelist = utils.NiceSort(self.cfg.GetInstanceList()) + i_non_redundant = [] # Non redundant instances node_volume = {} node_instance = {} node_info = {} @@ -831,6 +832,8 @@ class LUVerifyCluster(NoHooksLU): node_info[node] = { "mfree": int(nodeinfo['memory_free']), "dfree": int(nodeinfo['vg_free']), + "pinst": [], + "sinst": [], } except ValueError: feedback_fn(" - ERROR: invalid value returned from node %s" % (node,)) @@ -848,6 +851,32 @@ class LUVerifyCluster(NoHooksLU): inst_config.MapLVsByNode(node_vol_should) + pnode = inst_config.primary_node + if pnode in node_info: + node_info[pnode]['pinst'].append(instance) + else: + feedback_fn(" - ERROR: instance %s, connection to primary node" + " %s failed" % (instance, pnode)) + bad = True + + # If the instance is non-redundant we cannot survive losing its primary + # node, so we are not N+1 compliant. On the other hand we have no disk + # templates with more than one secondary so that situation is not well + # supported either. + # FIXME: does not support file-backed instances + if len(inst_config.secondary_nodes) == 0: + i_non_redundant.append(instance) + elif len(inst_config.secondary_nodes) > 1: + feedback_fn(" - WARNING: multiple secondaries for instance %s" + % instance) + + for snode in inst_config.secondary_nodes: + if snode in node_info: + node_info[snode]['sinst'].append(instance) + else: + feedback_fn(" - ERROR: instance %s, connection to secondary node" + " %s failed" % (instance, snode)) + feedback_fn("* Verifying orphan volumes") result = self._VerifyOrphanVolumes(node_vol_should, node_volume, feedback_fn) -- GitLab