"""
result = {}
- if 'hypervisor' in what:
- result['hypervisor'] = my_dict = {}
- for hv_name in what['hypervisor']:
- my_dict[hv_name] = hypervisor.GetHypervisor(hv_name).Verify()
-
- if 'filelist' in what:
- result['filelist'] = utils.FingerprintFiles(what['filelist'])
-
- if 'nodelist' in what:
- result['nodelist'] = {}
- random.shuffle(what['nodelist'])
- for node in what['nodelist']:
+ if constants.NV_HYPERVISOR in what:
+ result[constants.NV_HYPERVISOR] = tmp = {}
+ for hv_name in what[constants.NV_HYPERVISOR]:
+ tmp[hv_name] = hypervisor.GetHypervisor(hv_name).Verify()
+
+ if constants.NV_FILELIST in what:
+ result[constants.NV_FILELIST] = utils.FingerprintFiles(
+ what[constants.NV_FILELIST])
+
+ if constants.NV_NODELIST in what:
+ result[constants.NV_NODELIST] = tmp = {}
+ random.shuffle(what[constants.NV_NODELIST])
+ for node in what[constants.NV_NODELIST]:
success, message = _GetSshRunner(cluster_name).VerifyNodeHostname(node)
if not success:
- result['nodelist'][node] = message
- if 'node-net-test' in what:
- result['node-net-test'] = {}
+ tmp[node] = message
+
+ if constants.NV_NODENETTEST in what:
+ result[constants.NV_NODENETTEST] = tmp = {}
my_name = utils.HostInfo().name
my_pip = my_sip = None
- for name, pip, sip in what['node-net-test']:
+ for name, pip, sip in what[constants.NV_NODENETTEST]:
if name == my_name:
my_pip = pip
my_sip = sip
break
if not my_pip:
- result['node-net-test'][my_name] = ("Can't find my own"
- " primary/secondary IP"
- " in the node list")
+ tmp[my_name] = ("Can't find my own primary/secondary IP"
+ " in the node list")
else:
port = utils.GetNodeDaemonPort()
- for name, pip, sip in what['node-net-test']:
+ for name, pip, sip in what[constants.NV_NODENETTEST]:
fail = []
if not utils.TcpPing(pip, port, source=my_pip):
fail.append("primary")
if not utils.TcpPing(sip, port, source=my_sip):
fail.append("secondary")
if fail:
- result['node-net-test'][name] = ("failure using the %s"
- " interface(s)" %
- " and ".join(fail))
+ tmp[name] = ("failure using the %s interface(s)" %
+ " and ".join(fail))
+
+ if constants.NV_LVLIST in what:
+ result[constants.NV_LVLIST] = GetVolumeList(what[constants.NV_LVLIST])
+
+ if constants.NV_INSTANCELIST in what:
+ result[constants.NV_INSTANCELIST] = GetInstanceList(
+ what[constants.NV_INSTANCELIST])
+
+ if constants.NV_VGLIST in what:
+ result[constants.NV_VGLIST] = ListVolumeGroups()
+
+ if constants.NV_VERSION in what:
+ result[constants.NV_VERSION] = constants.PROTOCOL_VERSION
+
+ if constants.NV_HVINFO in what:
+ hyper = hypervisor.GetHypervisor(what[constants.NV_HVINFO])
+ result[constants.NV_HVINFO] = hyper.GetNodeInfo()
return result
}
self.share_locks = dict(((i, 1) for i in locking.LEVELS))
- def _VerifyNode(self, nodeinfo, file_list, local_cksum, vglist, node_result,
- remote_version, feedback_fn, master_files):
+ def _VerifyNode(self, nodeinfo, file_list, local_cksum,
+ node_result, feedback_fn, master_files):
"""Run multiple tests against a node.
Test list:
@param nodeinfo: the node to check
@param file_list: required list of files
@param local_cksum: dictionary of local files and their checksums
- @type vglist: dict
- @param vglist: dictionary of volume group names and their size
@param node_result: the results from the node
- @param remote_version: the RPC version from the remote node
@param feedback_fn: function used to accumulate results
@param master_files: list of files that only masters should have
"""
node = nodeinfo.name
+
+ # main result, node_result should be a non-empty dict
+ if not node_result or not isinstance(node_result, dict):
+ feedback_fn(" - ERROR: unable to verify node %s." % (node,))
+ return True
+
# compares ganeti version
local_version = constants.PROTOCOL_VERSION
+ remote_version = node_result.get('version', None)
if not remote_version:
feedback_fn(" - ERROR: connection to %s failed" % (node))
return True
# checks vg existance and size > 20G
bad = False
+ vglist = node_result.get(constants.NV_VGLIST, None)
if not vglist:
feedback_fn(" - ERROR: unable to check volume groups on node %s." %
(node,))
feedback_fn(" - ERROR: %s on node %s" % (vgstatus, node))
bad = True
- if not node_result:
- feedback_fn(" - ERROR: unable to verify node %s." % (node,))
- return True
-
# checks config file checksum
- # checks ssh to any
- if 'filelist' not in node_result:
+ remote_cksum = node_result.get(constants.NV_FILELIST, None)
+ if not isinstance(remote_cksum, dict):
bad = True
feedback_fn(" - ERROR: node hasn't returned file checksum data")
else:
- remote_cksum = node_result['filelist']
for file_name in file_list:
node_is_mc = nodeinfo.master_candidate
must_have_file = file_name not in master_files
feedback_fn(" - ERROR: file '%s' should not exist on non master"
" candidates" % file_name)
- if 'nodelist' not in node_result:
+ # checks ssh to any
+
+ if constants.NV_NODELIST not in node_result:
bad = True
feedback_fn(" - ERROR: node hasn't returned node ssh connectivity data")
else:
- if node_result['nodelist']:
+ if node_result[constants.NV_NODELIST]:
bad = True
- for node in node_result['nodelist']:
+ for node in node_result[constants.NV_NODELIST]:
feedback_fn(" - ERROR: ssh communication with node '%s': %s" %
- (node, node_result['nodelist'][node]))
- if 'node-net-test' not in node_result:
+ (node, node_result[constants.NV_NODELIST][node]))
+
+ if constants.NV_NODENETTEST not in node_result:
bad = True
feedback_fn(" - ERROR: node hasn't returned node tcp connectivity data")
else:
- if node_result['node-net-test']:
+ if node_result[constants.NV_NODENETTEST]:
bad = True
- nlist = utils.NiceSort(node_result['node-net-test'].keys())
+ nlist = utils.NiceSort(node_result[constants.NV_NODENETTEST].keys())
for node in nlist:
feedback_fn(" - ERROR: tcp communication with node '%s': %s" %
- (node, node_result['node-net-test'][node]))
+ (node, node_result[constants.NV_NODENETTEST][node]))
- hyp_result = node_result.get('hypervisor', None)
+ hyp_result = node_result.get(constants.NV_HYPERVISOR, None)
if isinstance(hyp_result, dict):
for hv_name, hv_result in hyp_result.iteritems():
if hv_result is not None:
local_checksums = utils.FingerprintFiles(file_names)
feedback_fn("* Gathering data (%d nodes)" % len(nodelist))
- all_volumeinfo = self.rpc.call_volume_list(nodelist, vg_name)
- all_instanceinfo = self.rpc.call_instance_list(nodelist, hypervisors)
- all_vglist = self.rpc.call_vg_list(nodelist)
node_verify_param = {
- 'filelist': file_names,
- 'nodelist': nodelist,
- 'hypervisor': hypervisors,
- 'node-net-test': [(node.name, node.primary_ip, node.secondary_ip)
- for node in nodeinfo]
+ constants.NV_FILELIST: file_names,
+ constants.NV_NODELIST: nodelist,
+ constants.NV_HYPERVISOR: hypervisors,
+ constants.NV_NODENETTEST: [(node.name, node.primary_ip,
+ node.secondary_ip) for node in nodeinfo],
+ constants.NV_LVLIST: vg_name,
+ constants.NV_INSTANCELIST: hypervisors,
+ constants.NV_VGLIST: None,
+ constants.NV_VERSION: None,
+ constants.NV_HVINFO: self.cfg.GetHypervisorType(),
}
all_nvinfo = self.rpc.call_node_verify(nodelist, node_verify_param,
self.cfg.GetClusterName())
- all_rversion = self.rpc.call_version(nodelist)
- all_ninfo = self.rpc.call_node_info(nodelist, self.cfg.GetVGName(),
- self.cfg.GetHypervisorType())
cluster = self.cfg.GetClusterInfo()
master_node = self.cfg.GetMasterNode()
for node_i in nodeinfo:
node = node_i.name
+ nresult = all_nvinfo[node].data
+
if node == master_node:
- ntype="master"
+ ntype = "master"
elif node_i.master_candidate:
- ntype="master candidate"
+ ntype = "master candidate"
else:
- ntype="regular"
+ ntype = "regular"
feedback_fn("* Verifying node %s (%s)" % (node, ntype))
+
+ if all_nvinfo[node].failed or not isinstance(nresult, dict):
+ feedback_fn(" - ERROR: connection to %s failed" % (node,))
+ bad = True
+ continue
+
result = self._VerifyNode(node_i, file_names, local_checksums,
- all_vglist[node], all_nvinfo[node],
- all_rversion[node], feedback_fn, master_files)
+ nresult, feedback_fn, master_files)
bad = bad or result
- # node_volume
- volumeinfo = all_volumeinfo[node]
-
- if isinstance(volumeinfo, basestring):
+ lvdata = nresult.get(constants.NV_LVLIST, "Missing LV data")
+ if isinstance(lvdata, basestring):
feedback_fn(" - ERROR: LVM problem on node %s: %s" %
- (node, volumeinfo[-400:].encode('string_escape')))
+ (node, lvdata.encode('string_escape')))
bad = True
node_volume[node] = {}
- elif not isinstance(volumeinfo, dict):
- feedback_fn(" - ERROR: connection to %s failed" % (node,))
+ elif not isinstance(lvdata, dict):
+ feedback_fn(" - ERROR: connection to %s failed (lvlist)" % (node,))
bad = True
continue
else:
- node_volume[node] = volumeinfo
+ node_volume[node] = lvdata
# node_instance
- nodeinstance = all_instanceinfo[node]
- if type(nodeinstance) != list:
- feedback_fn(" - ERROR: connection to %s failed" % (node,))
+ idata = nresult.get(constants.NV_INSTANCELIST, None)
+ if not isinstance(idata, list):
+ feedback_fn(" - ERROR: connection to %s failed (instancelist)" %
+ (node,))
bad = True
continue
- node_instance[node] = nodeinstance
+ node_instance[node] = idata
# node_info
- nodeinfo = all_ninfo[node]
+ nodeinfo = nresult.get(constants.NV_HVINFO, None)
if not isinstance(nodeinfo, dict):
- feedback_fn(" - ERROR: connection to %s failed" % (node,))
+ feedback_fn(" - ERROR: connection to %s failed (hvinfo)" % (node,))
bad = True
continue
try:
node_info[node] = {
"mfree": int(nodeinfo['memory_free']),
- "dfree": int(nodeinfo['vg_free']),
+ "dfree": int(nresult[constants.NV_VGLIST][vg_name]),
"pinst": [],
"sinst": [],
# dictionary holding all instances this node is secondary for,
for node_name in hooks_results:
show_node_header = True
res = hooks_results[node_name]
- if res is False or not isinstance(res, list):
- feedback_fn(" Communication failure")
+ if res.failed or res.data is False or not isinstance(res.data, list):
+ feedback_fn(" Communication failure in hooks execution")
lu_result = 1
continue
- for script, hkr, output in res:
+ for script, hkr, output in res.data:
if hkr == constants.HKR_FAIL:
# The node header is only shown once, if there are
# failing hooks on that node
found = False
for node in exportlist:
if exportlist[node].failed:
- self.Warning("Failed to query node %s, continuing" % node)
+ self.LogWarning("Failed to query node %s, continuing" % node)
continue
if instance_name in exportlist[node].data:
found = True