From d61bf5f0537350ab8f5e038ecf1dcf0404785984 Mon Sep 17 00:00:00 2001 From: zhangguoqing Date: Mon, 25 Apr 2016 21:04:20 +0800 Subject: [PATCH] [nova_helper] get keypair name by every admin users Since the bug #1182965 has been fixed, allow admin users to view any keypair. Change-Id: I9cf948701515afd45e6720cfd15cfac6b5866aa5 --- watcher/common/nova_helper.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index ce8ebd8b3..2db4bc33a 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -87,7 +87,6 @@ class NovaHelper(object): return False else: host_name = getattr(instance, "OS-EXT-SRV-ATTR:host") - # https://bugs.launchpad.net/nova/+bug/1182965 LOG.debug( "Instance %s found on host '%s'." % (instance_id, host_name)) @@ -532,16 +531,12 @@ class NovaHelper(object): "Trying to create new instance '%s' " "from image '%s' with flavor '%s' ..." % ( inst_name, image_id, flavor_name)) - # TODO(jed) wait feature - # Allow admin users to view any keypair - # https://bugs.launchpad.net/nova/+bug/1182965 - if not self.nova.keypairs.findall(name=keypair_name): - LOG.debug("Key pair '%s' not found with user '%s'" % ( - keypair_name, self.user)) + + try: + self.nova.keypairs.findall(name=keypair_name) + except nvexceptions.NotFound: + LOG.debug("Key pair '%s' not found " % keypair_name) return - else: - LOG.debug("Key pair '%s' found with user '%s'" % ( - keypair_name, self.user)) try: image = self.nova.images.get(image_id)