diff --git a/libra/mgm/drivers/hp_rest/driver.py b/libra/mgm/drivers/hp_rest/driver.py index b9240187..f5e4a004 100644 --- a/libra/mgm/drivers/hp_rest/driver.py +++ b/libra/mgm/drivers/hp_rest/driver.py @@ -50,7 +50,7 @@ class HPRestDriver(MgmDriver): return usage['free'] def is_online(self): - return self.is_online + return self.online def get_node_list(self, limit, marker): return self._get('{url}/devices'.format(url=self.url)) @@ -80,7 +80,7 @@ class HPRestDriver(MgmDriver): def _get(self, url): try: r = requests.get(url, verify=False) - except: + except requests.exceptions.RequestException: self.logger.error('Exception communicating to server: {exc}' .format(exc=sys.exc_info()[0])) return False, None @@ -94,7 +94,7 @@ class HPRestDriver(MgmDriver): def _post(self, url, node_data): try: r = requests.post(url, data=json.dumps(node_data), verify=False) - except: + except requests.exceptions.RequestException: self.logger.error('Exception communicating to server: {exc}' .format(exc=sys.exc_info()[0])) return False, None diff --git a/libra/mgm/nova.py b/libra/mgm/nova.py index b70532d8..41f65cdd 100644 --- a/libra/mgm/nova.py +++ b/libra/mgm/nova.py @@ -18,6 +18,7 @@ import sys import urllib from novaclient import client +from novaclient import exceptions class NotFound(Exception): @@ -52,7 +53,7 @@ class Node(object): node_id = uuid.uuid1() try: body = self._create(node_id) - except: + except exceptions.ClientException: return False, 'Error creating node {nid} exception {exc}'.format( nid=node_id, exc=sys.exc_info()[0] ) @@ -80,7 +81,7 @@ class Node(object): """ delete a node """ try: resp = self._delete(node_id) - except: + except exceptions.ClientException: return False, 'Error deleting node {nid} exception {exc}'.format( nid=node_id, exc=sys.exc_info()[0] )