for node_i in nodeinfo:
node = node_i.name
- nresult = all_nvinfo[node].data
if node_i.offline:
feedback_fn("* Skipping offline node %s" % (node,))
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,))
+ msg = all_nvinfo[node].RemoteFailMsg()
+ if msg:
+ feedback_fn(" - ERROR: while contacting node %s: %s" % (node, msg))
bad = True
continue
+ nresult = all_nvinfo[node].payload
node_drbd = {}
for minor, instance in all_drbd_map[node].items():
if instance not in instanceinfo:
finally:
result = self.rpc.call_node_start_master(master, False)
- if result.failed or not result.data:
+ msg = result.RemoteFailMsg()
+ if msg:
self.LogWarning("Could not re-enable the master role on"
- " the master, please restart manually.")
+ " the master, please restart manually: %s", msg)
def _RecursiveCheckIfLVMBased(disk):
self.cfg.GetHypervisorType())
for name in nodenames:
nodeinfo = node_data[name]
- if not nodeinfo.failed and nodeinfo.data:
- nodeinfo = nodeinfo.data
+ if not nodeinfo.RemoteFailMsg() and nodeinfo.payload:
+ nodeinfo = nodeinfo.payload
fn = utils.TryConvert
live_data[name] = {
"mtotal": fn(int, nodeinfo.get('memory_total', None)),
if new_node.secondary_ip != new_node.primary_ip:
result = self.rpc.call_node_has_ip_address(new_node.name,
new_node.secondary_ip)
- if result.failed or not result.data:
+ msg = result.RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Failure checking secondary ip"
+ " on node %s: %s" % (new_node.name, msg))
+ if not result.payload:
raise errors.OpExecError("Node claims it doesn't have the secondary ip"
" you gave (%s). Please fix and re-run this"
" command." % new_node.secondary_ip)
result = self.rpc.call_node_verify(node_verify_list, node_verify_param,
self.cfg.GetClusterName())
for verifier in node_verify_list:
- if result[verifier].failed or not result[verifier].data:
- raise errors.OpExecError("Cannot communicate with %s's node daemon"
- " for remote verification" % verifier)
- if result[verifier].data['nodelist']:
- for failed in result[verifier].data['nodelist']:
+ msg = result[verifier].RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Cannot communicate with node %s: %s" %
+ (verifier, msg))
+ nl_payload = result[verifier].payload['nodelist']
+ if nl_payload:
+ for failed in nl_payload:
feedback_fn("ssh/hostname verification failed %s -> %s" %
- (verifier, result[verifier].data['nodelist'][failed]))
+ (verifier, nl_payload[failed]))
raise errors.OpExecError("ssh/hostname verification failed.")
if self.op.readd:
_ShutdownInstanceDisks.
"""
- ins_l = lu.rpc.call_instance_list([instance.primary_node],
- [instance.hypervisor])
- ins_l = ins_l[instance.primary_node]
- if ins_l.failed or not isinstance(ins_l.data, list):
- raise errors.OpExecError("Can't contact node '%s'" %
- instance.primary_node)
-
- if instance.name in ins_l.data:
+ pnode = instance.primary_node
+ ins_l = lu.rpc.call_instance_list([pnode], [instance.hypervisor])
+ ins_l = ins_l[pnode]
+ msg = ins_l.RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Can't contact node %s: %s" % (pnode, msg))
+
+ if instance.name in ins_l.payload:
raise errors.OpExecError("Instance is running, can't shutdown"
" block devices.")
"""
nodeinfo = lu.rpc.call_node_info([node], lu.cfg.GetVGName(), hypervisor_name)
- nodeinfo[node].Raise()
- free_mem = nodeinfo[node].data.get('memory_free')
+ msg = nodeinfo[node].RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Can't get data from node %s: %s" % (node, msg))
+ free_mem = nodeinfo[node].payload.get('memory_free', None)
if not isinstance(free_mem, int):
raise errors.OpPrereqError("Can't compute free memory on node %s, result"
- " was '%s'" % (node, free_mem))
+ " was '%s'" % (node, free_mem))
if requested > free_mem:
raise errors.OpPrereqError("Not enough memory on node %s for %s:"
- " needed %s MiB, available %s MiB" %
- (node, reason, requested, free_mem))
+ " needed %s MiB, available %s MiB" %
+ (node, reason, requested, free_mem))
class LUStartupInstance(LogicalUnit):
remote_info = self.rpc.call_instance_info(instance.primary_node,
instance.name,
instance.hypervisor)
- remote_info.Raise()
- if not remote_info.data:
+ msg = remote_info.RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Error checking node %s: %s" %
+ (instance.primary_node, msg))
+ if not remote_info.payload: # not running already
_CheckNodeFreeMemory(self, instance.primary_node,
"starting instance %s" % instance.name,
bep[constants.BE_MEMORY], instance.hypervisor)
remote_info = self.rpc.call_instance_info(instance.primary_node,
instance.name,
instance.hypervisor)
- remote_info.Raise()
- if remote_info.data:
+ msg = remote_info.RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Error checking node %s: %s" %
+ (instance.primary_node, msg))
+ if remote_info.payload:
raise errors.OpPrereqError("Instance '%s' is running on the node %s" %
(self.op.instance_name,
instance.primary_node))
remote_info = self.rpc.call_instance_info(instance.primary_node,
instance.name,
instance.hypervisor)
- remote_info.Raise()
- if remote_info.data:
+ msg = remote_info.RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Error checking node %s: %s" %
+ (instance.primary_node, msg))
+ if remote_info.payload:
raise errors.OpPrereqError("Instance '%s' is running on the node %s" %
(self.op.instance_name,
instance.primary_node))
if result.offline:
# offline nodes will be in both lists
off_nodes.append(name)
- if result.failed:
+ if result.failed or result.RemoteFailMsg():
bad_nodes.append(name)
else:
- if result.data:
- live_data.update(result.data)
- # else no instance is alive
+ if result.payload:
+ live_data.update(result.payload)
+ # else no instance is alive
else:
live_data = dict([(name, {}) for name in instance_names])
" a bad state)")
ins_l = self.rpc.call_instance_list(self.all_nodes, [instance.hypervisor])
for node, result in ins_l.items():
- result.Raise()
- if not isinstance(result.data, list):
- raise errors.OpExecError("Can't contact node '%s'" % node)
+ msg = result.RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Can't contact node %s: %s" % (node, msg))
- runningon_source = instance.name in ins_l[source_node].data
- runningon_target = instance.name in ins_l[target_node].data
+ runningon_source = instance.name in ins_l[source_node].payload
+ runningon_target = instance.name in ins_l[target_node].payload
if runningon_source and runningon_target:
raise errors.OpExecError("Instance seems to be running on two nodes,"
self.op.hypervisor)
for node in nodenames:
info = nodeinfo[node]
- info.Raise()
- info = info.data
- if not info:
+ msg = info.RemoteFailMsg()
+ if msg:
raise errors.OpPrereqError("Cannot get current information"
- " from node '%s'" % node)
+ " from node %s: %s" % (node, msg))
+ info = info.payload
vg_free = info.get('vg_free', None)
if not isinstance(vg_free, int):
raise errors.OpPrereqError("Can't compute free disk space on"
" node %s" % node)
- if req_size > info['vg_free']:
+ if req_size > vg_free:
raise errors.OpPrereqError("Not enough disk space on target node %s."
" %d MB available, %d MB required" %
- (node, info['vg_free'], req_size))
+ (node, vg_free, req_size))
_CheckHVParams(self, nodenames, self.op.hypervisor, self.op.hvparams)
import_result = self.rpc.call_instance_os_import(pnode_name, iobj,
src_node, src_images,
cluster_name)
- import_result.Raise()
- for idx, result in enumerate(import_result.data):
- if not result:
- self.LogWarning("Could not import the image %s for instance"
- " %s, disk %d, on node %s" %
- (src_images[idx], instance, idx, pnode_name))
+ msg = import_result.RemoteFailMsg()
+ if msg:
+ self.LogWarning("Error while importing the disk images for instance"
+ " %s on node %s: %s" % (instance, pnode_name, msg))
else:
# also checked in the prereq part
raise errors.ProgrammerError("Unknown OS initialization mode '%s'"
node_insts = self.rpc.call_instance_list([node],
[instance.hypervisor])[node]
- node_insts.Raise()
+ msg = node_insts.RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Can't get node information from %s: %s" %
+ (node, msg))
- if instance.name not in node_insts.data:
+ if instance.name not in node_insts.payload:
raise errors.OpExecError("Instance %s is not running." % instance.name)
logging.debug("Connecting to console of %s on %s", instance.name, node)
instance.hypervisor)
for node in nodenames:
info = nodeinfo[node]
- if info.failed or not info.data:
+ msg = info.RemoteFailMsg()
+ if msg:
raise errors.OpPrereqError("Cannot get current information"
- " from node '%s'" % node)
- vg_free = info.data.get('vg_free', None)
+ " from node %s:" % (node, msg))
+ vg_free = info.payload.get('vg_free', None)
if not isinstance(vg_free, int):
raise errors.OpPrereqError("Can't compute free disk space on"
" node %s" % node)
remote_info = self.rpc.call_instance_info(instance.primary_node,
instance.name,
instance.hypervisor)
- remote_info.Raise()
- remote_info = remote_info.data
+ msg = remote_info.RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Error checking node %s: %s" %
+ (instance.primary_node, msg))
+ remote_info = remote_info.payload
if remote_info and "state" in remote_info:
remote_state = "up"
else:
instance.hypervisor)
nodeinfo = self.rpc.call_node_info(mem_check_list, self.cfg.GetVGName(),
instance.hypervisor)
- if nodeinfo[pnode].failed or not isinstance(nodeinfo[pnode].data, dict):
+ pninfo = nodeinfo[pnode]
+ msg = pninfo.RemoteFailMsg()
+ if msg:
# Assume the primary node is unreachable and go ahead
- self.warn.append("Can't get info from primary node %s" % pnode)
+ self.warn.append("Can't get info from primary node %s: %s" %
+ (pnode, msg))
+ elif not isinstance(pninfo.payload.get('memory_free', None), int):
+ self.warn.append("Node data from primary node %s doesn't contain"
+ " free memory information" % pnode)
+ elif instance_info.RemoteFailMsg():
+ self.warn.append("Can't get instance runtime information: %s" %
+ instance_info.RemoteFailMsg())
else:
- if not instance_info.failed and instance_info.data:
- current_mem = int(instance_info.data['memory'])
+ if instance_info.payload:
+ current_mem = int(instance_info.payload['memory'])
else:
# Assume instance not running
# (there is a slight race condition here, but it's not very probable,
# and we have no other way to check)
current_mem = 0
miss_mem = (be_new[constants.BE_MEMORY] - current_mem -
- nodeinfo[pnode].data['memory_free'])
+ pninfo.payload['memory_free'])
if miss_mem > 0:
raise errors.OpPrereqError("This change will prevent the instance"
" from starting, due to %d MB of memory"
" missing on its primary node" % miss_mem)
if be_new[constants.BE_AUTO_BALANCE]:
- for node, nres in nodeinfo.iteritems():
+ for node, nres in nodeinfo.items():
if node not in instance.secondary_nodes:
continue
- if nres.failed or not isinstance(nres.data, dict):
- self.warn.append("Can't get info from secondary node %s" % node)
- elif be_new[constants.BE_MEMORY] > nres.data['memory_free']:
+ msg = nres.RemoteFailMsg()
+ if msg:
+ self.warn.append("Can't get info from secondary node %s: %s" %
+ (node, msg))
+ elif not isinstance(nres.payload.get('memory_free', None), int):
+ self.warn.append("Secondary node %s didn't return free"
+ " memory information" % node)
+ elif be_new[constants.BE_MEMORY] > nres.payload['memory_free']:
self.warn.append("Not enough memory to failover instance to"
" secondary node %s" % node)
" an instance")
ins_l = self.rpc.call_instance_list([pnode], [instance.hypervisor])
ins_l = ins_l[pnode]
- if ins_l.failed or not isinstance(ins_l.data, list):
- raise errors.OpPrereqError("Can't contact node '%s'" % pnode)
- if instance.name in ins_l.data:
+ msg = ins_l.RemoteFailMsg()
+ if msg:
+ raise errors.OpPrereqError("Can't contact node %s: %s" %
+ (pnode, msg))
+ if instance.name in ins_l.payload:
raise errors.OpPrereqError("Instance is running, can't remove"
" disks.")
}
if not ninfo.offline:
- nresult.Raise()
- if not isinstance(nresult.data, dict):
- raise errors.OpExecError("Can't get data for node %s" % nname)
- remote_info = nresult.data
+ msg = nresult.RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Can't get data for node %s: %s" %
+ (nname, msg))
+ msg = node_iinfo[nname].RemoteFailMsg()
+ if msg:
+ raise errors.OpExecError("Can't get node instance info"
+ " from node %s: %s" % (nname, msg))
+ remote_info = nresult.payload
for attr in ['memory_total', 'memory_free', 'memory_dom0',
'vg_size', 'vg_free', 'cpu_total']:
if attr not in remote_info:
raise errors.OpExecError("Node '%s' didn't return attribute"
" '%s'" % (nname, attr))
- try:
- remote_info[attr] = int(remote_info[attr])
- except ValueError, err:
+ if not isinstance(remote_info[attr], int):
raise errors.OpExecError("Node '%s' returned invalid value"
- " for '%s': %s" % (nname, attr, err))
+ " for '%s': %s" %
+ (nname, attr, remote_info[attr]))
# compute memory used by primary instances
i_p_mem = i_p_up_mem = 0
for iinfo, beinfo in i_list:
if iinfo.primary_node == nname:
i_p_mem += beinfo[constants.BE_MEMORY]
- if iinfo.name not in node_iinfo[nname].data:
+ if iinfo.name not in node_iinfo[nname].payload:
i_used_mem = 0
else:
- i_used_mem = int(node_iinfo[nname].data[iinfo.name]['memory'])
+ i_used_mem = int(node_iinfo[nname].payload[iinfo.name]['memory'])
i_mem_diff = beinfo[constants.BE_MEMORY] - i_used_mem
remote_info['memory_free'] -= max(0, i_mem_diff)