From d0940a105162a528a7f7bf3dfc414e01fae66e46 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Thu, 20 Jun 2013 13:37:54 +0100 Subject: [PATCH] Work around https://github.com/nimbusproject/nimbus/issues/121 --- sandbox/FG/add_users.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sandbox/FG/add_users.py b/sandbox/FG/add_users.py index 173f2a1..d8dfb4c 100755 --- a/sandbox/FG/add_users.py +++ b/sandbox/FG/add_users.py @@ -61,8 +61,12 @@ def register_key_with_iaas(iaas_url, keytext, keyname, access_key, access_secret # Workaround for a bug in Nimbus <= 2.10.1: # import_key_pair does not properly update an existing key - if ec2conn.get_key_pair(keyname) is not None: - ec2conn.delete_key_pair(keyname) + try: + if ec2conn.get_key_pair(keyname) is not None: + ec2conn.delete_key_pair(keyname) + except IndexError: + # This exception is raised when boto can't find a key on Nimbus + pass ec2conn.import_key_pair(keyname, keytext)