Fix exception handling in novaclient

novaclient.exceptions wasn't being imported so was causing a 500
to be thrown if nova raised an exception.

Also rename the novaclient variable to nova to avoid mirroring
an import name.

Change-Id: Ic699c5231b74641bcd8baec4a5761a3fcae726f1
This commit is contained in:
Rob Crittenden
2017-01-05 16:31:59 +00:00
parent aaf832f0ab
commit db6fc902b0

View File

@@ -15,6 +15,7 @@
"""Handle communication with Nova."""
from novaclient import client
from novaclient import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@@ -44,8 +45,8 @@ class NovaClient(object):
def get_instance(instance_id):
novaclient = NovaClient()
client = NovaClient()
try:
return novaclient.client.servers.get(instance_id)
except novaclient.exceptions.NotFound:
return client.client.servers.get(instance_id)
except exceptions.NotFound:
return None