X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/81010134cfee8b3a744185398ab384ed2e5aebe5..68676a00a95239fcdd935758b7f6144cbec8b0fc:/lib/rpc.py?ds=inline diff --git a/lib/rpc.py b/lib/rpc.py index 0e4b5dc..f2c85db 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -38,6 +38,7 @@ from ganeti import constants from ganeti import objects from ganeti import ssconf + class NodeController: """Node-handling class. @@ -207,6 +208,18 @@ def call_instance_shutdown(node, instance): return c.getresult().get(node, False) +def call_instance_migrate(node, instance, target, live): + """Migrate an instance. + + This is a single-node call. + + """ + c = Client("instance_migrate", [instance.name, target, live]) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + def call_instance_reboot(node, instance, reboot_type, extra_args): """Reboots an instance. @@ -499,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) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + def call_upload_file(node_list, file_name): """Upload a file. @@ -576,6 +602,36 @@ def call_hooks_runner(node_list, hpath, phase, env): return result +def call_iallocator_runner(node, name, idata): + """Call an iallocator on a remote node + + Args: + - name: the iallocator name + - input: the json-encoded input string + + This is a single-node call. + + """ + params = [name, idata] + c = Client("iallocator_runner", params) + c.connect(node) + c.run() + result = c.getresult().get(node, False) + return result + + +def call_blockdev_grow(node, cf_bdev, amount): + """Request a snapshot of the given block device. + + This is a single-node call. + + """ + c = Client("blockdev_grow", [cf_bdev.ToDict(), amount]) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + def call_blockdev_snapshot(node, cf_bdev): """Request a snapshot of the given block device. @@ -631,7 +687,7 @@ def call_export_info(node, path): result = c.getresult().get(node, False) if not result: return result - return objects.SerializableConfigParser.Loads(result) + return objects.SerializableConfigParser.Loads(str(result)) def call_instance_os_import(node, inst, osdev, swapdev, src_node, src_image): @@ -709,3 +765,42 @@ def call_test_delay(node_list, duration): c.connect_list(node_list) c.run() return c.getresult() + + +def call_file_storage_dir_create(node, file_storage_dir): + """Create the given file storage directory. + + This is a single-node call. + + """ + c = Client("file_storage_dir_create", [file_storage_dir]) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + +def call_file_storage_dir_remove(node, file_storage_dir): + """Remove the given file storage directory. + + This is a single-node call. + + """ + c = Client("file_storage_dir_remove", [file_storage_dir]) + c.connect(node) + c.run() + return c.getresult().get(node, False) + + +def call_file_storage_dir_rename(node, old_file_storage_dir, + new_file_storage_dir): + """Rename file storage directory. + + This is a single-node call. + + """ + c = Client("file_storage_dir_rename", + [old_file_storage_dir, new_file_storage_dir]) + c.connect(node) + c.run() + return c.getresult().get(node, False) +