From d15a9ad3eeb2860a9e6f9bc6028a705cae55e4e9 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Fri, 17 Oct 2008 14:37:00 +0000
Subject: [PATCH] Cleanup os_add/rename rpc for OS API 10

- remove now unused osdev and swapdev arguments from backend, noded,
  rpc, cmdlib
- convert docstrings to epydoc

Reviewed-by: iustinp
---
 daemons/ganeti-noded |  8 ++++----
 lib/backend.py       | 19 ++++++++-----------
 lib/cmdlib.py        |  5 ++---
 lib/rpc.py           |  8 ++++----
 4 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 8116b9b1d..6b73fc5b9 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -321,18 +321,18 @@ class NodeHttpServer(http.HttpServer):
     """Install an OS on a given instance.
 
     """
-    inst_s, os_disk, swap_disk = params
+    inst_s = params[0]
     inst = objects.Instance.FromDict(inst_s)
-    return backend.AddOSToInstance(inst, os_disk, swap_disk)
+    return backend.AddOSToInstance(inst)
 
   @staticmethod
   def perspective_instance_run_rename(params):
     """Runs the OS rename script for an instance.
 
     """
-    inst_s, old_name, os_disk, swap_disk = params
+    inst_s, old_name = params
     inst = objects.Instance.FromDict(inst_s)
-    return backend.RunRenameInstance(inst, old_name, os_disk, swap_disk)
+    return backend.RunRenameInstance(inst, old_name)
 
   @staticmethod
   def perspective_instance_os_import(params):
diff --git a/lib/backend.py b/lib/backend.py
index d52b3552b..7e25c682e 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -516,13 +516,11 @@ def GetAllInstancesInfo(hypervisor_list):
   return output
 
 
-def AddOSToInstance(instance, os_disk, swap_disk):
+def AddOSToInstance(instance):
   """Add an OS to an instance.
 
-  Args:
-    instance: the instance object
-    os_disk: the instance-visible name of the os device
-    swap_disk: the instance-visible name of the swap device
+  @type instance: L{objects.Instance}
+  @param instance: Instance whose OS is to be installed
 
   """
   inst_os = OSFromDisk(instance.os)
@@ -548,14 +546,13 @@ def AddOSToInstance(instance, os_disk, swap_disk):
   return True
 
 
-def RunRenameInstance(instance, old_name, os_disk, swap_disk):
+def RunRenameInstance(instance, old_name):
   """Run the OS rename script for an instance.
 
-  Args:
-    instance: the instance object
-    old_name: the old name of the instance
-    os_disk: the instance-visible name of the os device
-    swap_disk: the instance-visible name of the swap device
+  @type instance: objects.Instance
+  @param instance: Instance whose OS is to be installed
+  @type old_name: string
+  @param old_name: previous instance name
 
   """
   inst_os = OSFromDisk(instance.os)
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 940dd8a91..458e5b79b 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2583,8 +2583,7 @@ class LURenameInstance(LogicalUnit):
     _StartInstanceDisks(self, inst, None)
     try:
       if not self.rpc.call_instance_run_rename(inst.primary_node, inst,
-                                               old_name,
-                                               "sda", "sdb"):
+                                               old_name):
         msg = ("Could not run OS rename script for instance %s on node %s"
                " (but the instance has been renamed in Ganeti)" %
                (inst.name, inst.primary_node))
@@ -3682,7 +3681,7 @@ class LUCreateInstance(LogicalUnit):
     if iobj.disk_template != constants.DT_DISKLESS:
       if self.op.mode == constants.INSTANCE_CREATE:
         feedback_fn("* running the instance OS create scripts...")
-        if not self.rpc.call_instance_os_add(pnode_name, iobj, "sda", "sdb"):
+        if not self.rpc.call_instance_os_add(pnode_name, iobj):
           raise errors.OpExecError("could not add os for instance %s"
                                    " on node %s" %
                                    (instance, pnode_name))
diff --git a/lib/rpc.py b/lib/rpc.py
index 18c07cd8c..b2dbdbee2 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -269,25 +269,25 @@ class RpcRunner(object):
     c.run()
     return c.getresult().get(node, False)
 
-  def call_instance_os_add(self, node, inst, osdev, swapdev):
+  def call_instance_os_add(self, node, inst):
     """Installs an OS on the given instance.
 
     This is a single-node call.
 
     """
-    params = [self._InstDict(inst), osdev, swapdev]
+    params = [self._InstDict(inst)]
     c = Client("instance_os_add", params)
     c.connect(node)
     c.run()
     return c.getresult().get(node, False)
 
-  def call_instance_run_rename(self, node, inst, old_name, osdev, swapdev):
+  def call_instance_run_rename(self, node, inst, old_name):
     """Run the OS rename script for an instance.
 
     This is a single-node call.
 
     """
-    params = [self._InstDict(inst), old_name, osdev, swapdev]
+    params = [self._InstDict(inst), old_name]
     c = Client("instance_run_rename", params)
     c.connect(node)
     c.run()
-- 
GitLab