Commit f81c4737 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add RPC call to send SIGTERM to import/export daemon



This will be used to stop the daemon without doing complete cleanup (yet).
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent ef40fbfb
......@@ -890,6 +890,13 @@ class NodeHttpServer(http.server.HttpServer):
"""
return backend.GetImportExportStatus(params[0])
@staticmethod
def perspective_impexp_abort(params):
"""Aborts an import or export.
"""
return backend.AbortImportExport(params[0])
@staticmethod
def perspective_impexp_cleanup(params):
"""Cleans up after an import or export.
......
......@@ -47,6 +47,7 @@ import logging
import tempfile
import zlib
import base64
import signal
from ganeti import errors
from ganeti import utils
......@@ -2845,6 +2846,21 @@ def GetImportExportStatus(names):
return result
def AbortImportExport(name):
"""Sends SIGTERM to a running import/export daemon.
"""
logging.info("Abort import/export %s", name)
status_dir = utils.PathJoin(constants.IMPORT_EXPORT_DIR, name)
pid = utils.ReadLockedPidFile(utils.PathJoin(status_dir, _IES_PID_FILE))
if pid:
logging.info("Import/export %s is running with PID %s, sending SIGTERM",
name, pid)
os.kill(pid, signal.SIGTERM)
def CleanupImportExport(name):
"""Cleanup after an import or export.
......
......@@ -1288,6 +1288,19 @@ class RpcRunner(object):
return result
def call_impexp_abort(self, node, name):
"""Aborts an import or export.
This is a single-node call.
@type node: string
@param node: Node name
@type name: string
@param name: Import/export name
"""
return self._SingleNodeCall(node, "impexp_abort", [name])
def call_impexp_cleanup(self, node, name):
"""Cleans up after an import or export.
......
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