Don't fall when just loading neutronv2 modules
this avoids loading warnings on salt-master that may not have
os-client-config installed, as salt tries to load them irrespective of
__virtual__() result.
Change-Id: I6d1a15c1dbdf0d95efb57e5aa41bae3d4b0eb7bf
Related-Issue: https://mirantis.jira.com/browse/PROD-27276
diff --git a/_modules/neutronv2/common.py b/_modules/neutronv2/common.py
index 699c6d9..88c08b6 100644
--- a/_modules/neutronv2/common.py
+++ b/_modules/neutronv2/common.py
@@ -1,9 +1,13 @@
import functools
import logging
-import os_client_config
import time
-from salt.exceptions import CommandExecutionError
+try:
+ import os_client_config
+except ImportError:
+ os_client_config = None
+from salt import exceptions
+
log = logging.getLogger(__name__)
@@ -49,6 +53,10 @@
def _get_raw_client(cloud_name):
+ if not os_client_config:
+ raise exceptions.SaltInvocationError(
+ "Cannot load os-client-config. Please check your environment "
+ "configuration.")
service_type = 'network'
config = os_client_config.OpenStackConfig()
cloud = config.get_one_cloud(cloud_name)
@@ -130,7 +138,7 @@
break
if not response or not response.content:
if e:
- raise CommandExecutionError(e)
+ raise exceptions.CommandExecutionError(e)
else:
return {}
try: