Commit d61cbe76 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a rpc call for BlockDev.Close()

This patch adds rpc layer calls (in and the equivalent in
ganeti-noded) to close a list of block devices, and the wrapper in that takes a list of Disk objects, identifies them and
returns correctly formatted results.

The reason why this very basic call was missing until now from the rpc
layer is that we usually don't care about device closes (though we
should, and will do so in the future) as only drbd has a meaningful
Close() operation; right now we directly do Shutdown().

The patch is clean enough that it's actually independent of the live
migration implementation.

Reviewed-by: imsnah
parent 1efbe18e
......@@ -220,6 +220,14 @@ class ServerObject(BaseHTTPServer.BaseHTTPRequestHandler):
amount = params[1]
return backend.GrowBlockDevice(cfbd, amount)
def perspective_blockdev_close(params):
"""Closes the given block devices.
disks = [objects.Disk.FromDict(cf) for cf in params]
return backend.CloseBlockDevices(disks)
# export/import --------------------------
......@@ -1477,7 +1477,7 @@ def _TransformFileStorageDir(file_storage_dir):
file_storage_dir: string with path
normalized file_storage_dir (string) if valid, None otherwise
......@@ -1592,6 +1592,31 @@ def RenameFileStorageDir(old_file_storage_dir, new_file_storage_dir):
return result
def CloseBlockDevices(disks):
"""Closes the given block devices.
This means they will be switched to secondary mode (in case of DRBD).
bdevs = []
for cf in disks:
rd = _RecursiveFindBD(cf)
if rd is None:
return (False, "Can't find device %s" % cf)
msg = []
for rd in bdevs:
except errors.BlockDeviceError, err:
if msg:
return (False, "Can't make devices secondary: %s" % ",".join(msg))
return (True, "All devices secondary")
class HooksRunner(object):
"""Hook runner.
......@@ -512,6 +512,19 @@ def call_blockdev_find(node, disk):
return c.getresult().get(node, False)
def call_blockdev_close(node, disks):
"""Closes the given block devices.
This is a single-node call.
params = [cf.ToDict() for cf in disks]
c = Client("blockdev_close", params)
return c.getresult().get(node, False)
def call_upload_file(node_list, file_name):
"""Upload a file.
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