Move function cleaning directory to module level
[ganeti-local] / lib / rpc.py
index 57f0a8e..68ac0bc 100644 (file)
@@ -33,8 +33,6 @@ import simplejson
 
 from ganeti import logger
 from ganeti import utils
-from ganeti import errors
-from ganeti import constants
 from ganeti import objects
 from ganeti import ssconf
 
@@ -208,6 +206,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.
 
@@ -350,25 +360,25 @@ def call_node_verify(node_list, checkdict):
   return c.getresult()
 
 
-def call_node_start_master(node):
+def call_node_start_master(node, start_daemons):
   """Tells a node to activate itself as a master.
 
   This is a single-node call.
 
   """
-  c = Client("node_start_master", [])
+  c = Client("node_start_master", [start_daemons])
   c.connect(node)
   c.run()
   return c.getresult().get(node, False)
 
 
-def call_node_stop_master(node):
+def call_node_stop_master(node, stop_daemons):
   """Tells a node to demote itself from master status.
 
   This is a single-node call.
 
   """
-  c = Client("node_stop_master", [])
+  c = Client("node_stop_master", [stop_daemons])
   c.connect(node)
   c.run()
   return c.getresult().get(node, False)
@@ -500,6 +510,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.
 
@@ -577,6 +600,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.
 
@@ -748,4 +801,3 @@ def call_file_storage_dir_rename(node, old_file_storage_dir,
   c.connect(node)
   c.run()
   return c.getresult().get(node, False)
-