mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
states: glance: import keystone exceptions from new location
keystoneclient.apiclient.exceptions has been deprecated since 0.7.1 in favor of keystoneclient.exceptions, and has been removed in 2.1.0, so the glance state fails to load with recent versions of keystoneclient. This commit tries to import from keystoneclient.exceptions first, and falls back to keystoneclient.apiclient.exceptions if that fails.
This commit is contained in:
parent
81c935f210
commit
02b91ecf15
1 changed files with 14 additions and 4 deletions
|
@ -13,13 +13,23 @@ from salt.utils import warn_until
|
|||
|
||||
# Import OpenStack libs
|
||||
try:
|
||||
from keystoneclient.apiclient.exceptions import \
|
||||
from keystoneclient.exceptions import \
|
||||
Unauthorized as kstone_Unauthorized
|
||||
HAS_KEYSTONE = True
|
||||
except ImportError:
|
||||
try:
|
||||
from keystoneclient.apiclient.exceptions import \
|
||||
Unauthorized as kstone_Unauthorized
|
||||
HAS_KEYSTONE = True
|
||||
except ImportError:
|
||||
HAS_KEYSTONE = False
|
||||
|
||||
try:
|
||||
from glanceclient.exc import \
|
||||
HTTPUnauthorized as glance_Unauthorized
|
||||
HAS_DEPENDENCIES = True
|
||||
HAS_GLANCE = True
|
||||
except ImportError:
|
||||
HAS_DEPENDENCIES = False
|
||||
HAS_GLANCE = False
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -28,7 +38,7 @@ def __virtual__():
|
|||
'''
|
||||
Only load if dependencies are loaded
|
||||
'''
|
||||
return HAS_DEPENDENCIES
|
||||
return HAS_KEYSTONE and HAS_GLANCE
|
||||
|
||||
|
||||
def _find_image(name):
|
||||
|
|
Loading…
Add table
Reference in a new issue