LUExportInstance: snapshot all disks
[ganeti-local] / lib / backend.py
index d52b355..6aa8c83 100644 (file)
@@ -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)
@@ -1305,11 +1302,10 @@ def SnapshotBlockDevice(disk):
   This function is called recursively, and the snapshot is actually created
   just for the leaf lvm backend device.
 
-  Args:
-    disk: the disk to be snapshotted
-
-  Returns:
-    a config entry for the actual lvm device snapshotted.
+  @type disk: L{objects.Disk}
+  @param disk: the disk to be snapshotted
+  @rtype: string
+  @return: snapshot disk path
 
   """
   if disk.children:
@@ -1440,12 +1436,13 @@ def FinalizeExport(instance, snap_disks):
 
   disk_count = 0
   for disk_count, disk in enumerate(snap_disks):
-    config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count,
-               ('%s' % disk.iv_name))
-    config.set(constants.INISECT_INS, 'disk%d_dump' % disk_count,
-               ('%s' % disk.physical_id[1]))
-    config.set(constants.INISECT_INS, 'disk%d_size' % disk_count,
-               ('%d' % disk.size))
+    if disk:
+      config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count,
+                 ('%s' % disk.iv_name))
+      config.set(constants.INISECT_INS, 'disk%d_dump' % disk_count,
+                 ('%s' % disk.physical_id[1]))
+      config.set(constants.INISECT_INS, 'disk%d_size' % disk_count,
+                 ('%d' % disk.size))
   config.set(constants.INISECT_INS, 'disk_count' , '%d' % disk_count)
 
   cff = os.path.join(destdir, constants.EXPORT_CONF_FILE)