Use common functions for handling import errors (#51851)

* Use common functions for handling import errors

* use refactored version of gitlab modules
This commit is contained in:
Jordan Borean 2019-02-08 07:51:16 +10:00 committed by Sam Doran
commit c1e51ef486
39 changed files with 233 additions and 93 deletions

View file

@ -27,11 +27,16 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import traceback
from ansible.module_utils.basic import missing_required_lib
UCSMSDK_IMP_ERR = None
try:
import ucsmsdk
HAS_UCSMSDK = True
except Exception:
UCSMSDK_IMP_ERR = traceback.format_exc()
HAS_UCSMSDK = False
ucs_argument_spec = dict(
@ -51,7 +56,7 @@ class UCSModule():
self.module = module
self.result = {}
if not HAS_UCSMSDK:
self.module.fail_json(msg='ucsmsdk is required for this module')
self.module.fail_json(msg=missing_required_lib('ucsmsdk'), exception=UCSMSDK_IMP_ERR)
self.login()
def __del__(self):