Commit 35fbcd11 authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert export_remove rpc to new style



This converts the export_remove rpc to new style result and also fixes
and old TODO by adding exception handling (and conversion to failure).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 1b7bfbb7
......@@ -1979,11 +1979,12 @@ def RemoveExport(export):
"""
target = os.path.join(constants.EXPORT_DIR, export)
shutil.rmtree(target)
# TODO: catch some of the relevant exceptions and provide a pretty
# error message if rmtree fails.
try:
shutil.rmtree(target)
except EnvironmentError, err:
_Fail("Error while removing the export: %s", err, exc=True)
return True
return True, None
def BlockdevRename(devlist):
......
......@@ -6516,15 +6516,17 @@ class LUExportInstance(LogicalUnit):
# on one-node clusters nodelist will be empty after the removal
# if we proceed the backup would be removed because OpQueryExports
# substitutes an empty list with the full cluster node list.
iname = instance.name
if nodelist:
exportlist = self.rpc.call_export_list(nodelist)
for node in exportlist:
if exportlist[node].RemoteFailMsg():
continue
if instance.name in exportlist[node].payload:
if not self.rpc.call_export_remove(node, instance.name):
if iname in exportlist[node].payload:
msg = self.rpc.call_export_remove(node, iname).RemoteFailMsg()
if msg:
self.LogWarning("Could not remove older export for instance %s"
" on node %s", instance.name, node)
" on node %s: %s", iname, node, msg)
class LURemoveExport(NoHooksLU):
......@@ -6569,9 +6571,10 @@ class LURemoveExport(NoHooksLU):
if instance_name in exportlist[node].payload:
found = True
result = self.rpc.call_export_remove(node, instance_name)
if result.failed or not result.data:
msg = result.RemoteFailMsg()
if msg:
logging.error("Could not remove export for instance %s"
" on node %s", instance_name, node)
" on node %s: %s", instance_name, node, msg)
if fqdn_warn and not found:
feedback_fn("Export not found. If trying to remove an export belonging"
......
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