Commit 1b54fc6c authored by Guido Trotter's avatar Guido Trotter
Browse files

Convert UploadFile (and its callers) to new rpc


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4501a443
......@@ -1459,9 +1459,9 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
"""
if not os.path.isabs(file_name):
logging.error("Filename passed to UploadFile is not absolute: '%s'",
file_name)
return False
err = "Filename passed to UploadFile is not absolute: '%s'" % file_name
logging.error(err)
return (False, err)
allowed_files = set([
constants.CLUSTER_CONF_FILE,
......@@ -1477,15 +1477,16 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
allowed_files.update(hv_class.GetAncillaryFiles())
if file_name not in allowed_files:
logging.error("Filename passed to UploadFile not in allowed"
" upload targets: '%s'", file_name)
return False
err = "Filename passed to UploadFile not in allowed upload targets: '%s'" \
% file_name
logging.error(err)
return (False, err)
raw_data = _Decompress(data)
utils.WriteFile(file_name, data=raw_data, mode=mode, uid=uid, gid=gid,
atime=atime, mtime=mtime)
return True
return (True, "success")
def WriteSsconfFiles(values):
......
......@@ -1381,9 +1381,11 @@ class LURenameCluster(LogicalUnit):
result = self.rpc.call_upload_file(node_list,
constants.SSH_KNOWN_HOSTS_FILE)
for to_node, to_result in result.iteritems():
if to_result.failed or not to_result.data:
logging.error("Copy of file %s to node %s failed",
constants.SSH_KNOWN_HOSTS_FILE, to_node)
msg = to_result.RemoteFailMsg()
if msg:
msg = ("Copy of file %s to node %s failed: %s" %
(constants.SSH_KNOWN_HOSTS_FILE, to_node, msg))
self.proc.LogWarning(msg)
finally:
result = self.rpc.call_node_start_master(master, False)
......@@ -1583,8 +1585,11 @@ def _RedistributeAncillaryFiles(lu, additional_nodes=None):
if os.path.exists(fname):
result = lu.rpc.call_upload_file(dist_nodes, fname)
for to_node, to_result in result.items():
if to_result.failed or not to_result.data:
logging.error("Copy of file %s to node %s failed", fname, to_node)
msg = to_result.RemoteFailMsg()
if msg:
msg = ("Copy of file %s to node %s failed: %s" %
(fname, to_node, msg))
lu.proc.LogWarning(msg)
class LURedistributeConfig(NoHooksLU):
......
......@@ -1066,10 +1066,12 @@ class ConfigWriter:
result = rpc.RpcRunner.call_upload_file(node_list, self._cfg_file,
address_list=addr_list)
for node in node_list:
if not result[node]:
logging.error("copy of file %s to node %s failed",
self._cfg_file, node)
for to_node, to_result in result.items():
msg = to_result.RemoteFailMsg()
if msg:
msg = ("Copy of file %s to node %s failed: %s" %
(self._cfg_file, node, msg))
logging.error(msg)
bad = True
return not bad
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment