From 9716fdcead7eeb045d8b8903a396709231af66de Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 17 Sep 2007 11:53:53 +0000 Subject: [PATCH] A few minor fixes in backend.py This uses the recently-added Instance.FindDisk() method instead of hard coded find-disk code. It also renames one parameter to AddNode from ssh to sshkey in order not to shadow the ganeti.ssh module. Reviewed-by: imsnah --- lib/backend.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index af4a4d80f..24374d344 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -79,7 +79,7 @@ def StopMaster(): return True -def AddNode(dsa, dsapub, rsa, rsapub, ssh, sshpub): +def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub): """ adds the node to the cluster - updates the hostkey - adds the ssh-key @@ -107,7 +107,7 @@ def AddNode(dsa, dsapub, rsa, rsapub, ssh, sshpub): os.mkdir("/root/.ssh") f = open("/root/.ssh/id_dsa", 'w') - f.write(ssh) + f.write(sshkey) f.close() f = open("/root/.ssh/id_dsa.pub", 'w') @@ -369,17 +369,13 @@ def AddOSToInstance(instance, os_disk, swap_disk): create_script = inst_os.create_script - for os_device in instance.disks: - if os_device.iv_name == os_disk: - break - else: + os_device = instance.FindDisk(os_disk) + if os_device is None: logger.Error("Can't find this device-visible name '%s'" % os_disk) return False - for swap_device in instance.disks: - if swap_device.iv_name == swap_disk: - break - else: + swap_device = instance.FindDisk(swap_disk) + if swap_device is None: logger.Error("Can't find this device-visible name '%s'" % swap_disk) return False @@ -1199,17 +1195,13 @@ def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image): inst_os = OSFromDisk(instance.os) import_script = inst_os.import_script - for os_device in instance.disks: - if os_device.iv_name == os_disk: - break - else: + os_device = instance.FindDisk(os_disk) + if os_device is None: logger.Error("Can't find this device-visible name '%s'" % os_disk) return False - for swap_device in instance.disks: - if swap_device.iv_name == swap_disk: - break - else: + swap_device = instance.FindDisk(swap_disk) + if swap_device is None: logger.Error("Can't find this device-visible name '%s'" % swap_disk) return False -- GitLab